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 8f8f63697714904c1d6c871c1e8e3df197e0298e..c14455d0ac760c6d3f4c5ea7aeba52ed4549a8b1 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);
                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;
 }
 
        return conf;
 }