Tests: fix: leak caused by misuse of realloc in multi-lib-test
[lttng-tools.git] / tests / regression / ust / multi-lib / multi-lib-test.c
index e145aa21aeae49e8310dc498c40e301499b88126..b5b2f314764af0ee5ff32706b1850fc464e34821 100644 (file)
@@ -201,12 +201,15 @@ int main(int argc, const char **argv)
         * Populate the libraries array with the arguments passed to the process.
         */
        while (poptPeekArg(optCon) != NULL) {
+               char **realloced_libraries = NULL;
+
                nb_libraries++;
-               libraries = realloc(libraries, nb_libraries * sizeof(char *));
-               if (!libraries) {
+               realloced_libraries = realloc(libraries, nb_libraries * sizeof(char *));
+               if (!realloced_libraries) {
                        ret = -1;
                        goto error;
                }
+               libraries = realloced_libraries;
                libraries[nb_libraries - 1] = (char *) poptGetArg(optCon);
        }
 
This page took 0.023169 seconds and 4 git commands to generate.