From d07256a96dd38ec39b21fcbb31f0db6264cf5fda Mon Sep 17 00:00:00 2001 From: Gautham B A Date: Wed, 20 Jul 2022 21:57:28 +0530 Subject: [PATCH] HDFS-16667. Use malloc for buffer allocation in uriparser2 (#4576) * Windows doesn't support variables for specifying the array size. * This PR uses malloc to fix this issue. --- .../third_party/uriparser2/uriparser2/uriparser2.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/third_party/uriparser2/uriparser2/uriparser2.c b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/third_party/uriparser2/uriparser2/uriparser2.c index ab6209c864..3036acfd35 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/third_party/uriparser2/uriparser2/uriparser2.c +++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/third_party/uriparser2/uriparser2/uriparser2.c @@ -71,9 +71,11 @@ static const char *copy_path(const UriPathSegmentA *ps, char **buffer) { static int parse_int(const char *first, const char *after_last) { const int size = after_last - first; if (size) { - char buffer[size + 1]; + char* buffer = (char*) malloc(size + 1); memcpyz(buffer, first, size); - return atoi(buffer); + const int value = atoi(buffer); + free(buffer); + return value; } return 0; }