Преглед изворни кода

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.
Gautham B A пре 2 година
родитељ
комит
d07256a96d

+ 4 - 2
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;
 }