recv_common: fix memory leak and invalid free in error path
authorAndre Noll <maan@systemlinux.org>
Sun, 11 Feb 2007 22:45:52 +0000 (23:45 +0100)
committerAndre Noll <maan@systemlinux.org>
Sun, 11 Feb 2007 22:45:52 +0000 (23:45 +0100)
As split_args() returns pointers that point within the given string,
it is wrong to free the individual pieces. However, the array of
substrings must be freed. parse_receiver_args() got both of these
wrong :(

recv_common.c

index 8f8f636..c14455d 100644 (file)
@@ -51,12 +51,7 @@ static void *parse_receiver_args(int receiver_num, char *options)
                argv[1] = NULL;
        }
        conf = r->parse_config(argc, argv);
-       if (!conf) {
-               for (i = 0; i < argc; i++)
-                       free(argv[i]);
-               free(argv);
-               return NULL;
-       }
+       free(argv);
        return conf;
 }