[distcc] 2 coding errors

Michael Donohue michael.donohue at gmail.com
Wed Feb 22 00:11:33 GMT 2006

There's an error in the function dcc_free_argv.   The call to free(a) should
really be free(*a), since the former is calling free on the array itself,
instead of the memory allocated.
The short function is below:

void dcc_free_argv(char **argv)
    char **a;

    for (a = argv; *a != NULL; a++)
        free(a);  // should be free(*a);

Eclipse's CDT reported this one, and it is a bug:
the loop increment logic is incorrect for dcc_argv_search, as "a = a++" is
undefined.     It should just be "a++"

int dcc_argv_search(char **a,
                    const char *needle)
    for (; *a; a = a++) // should be a++
        if (!strcmp(*a, needle))
            return 1;
    return 0;

Both functions are in argutil.c
-------------- next part --------------
HTML attachment scrubbed and removed

More information about the distcc mailing list