[Cocci] Question to stackoverflow answer for finding malloc assignment not followed by if NULL test
Håkon Løvdal
hlovdal at gmail.com
Tue Nov 17 18:17:28 CET 2009
Julia has already answered my question about how to add missing
NULL tests after malloc
(http://stackoverflow.com/questions/1716086/adding-missing-null-checks-after-malloc-with-coccinelle).
However, the semantic patch fails to correct variables that
are initialized with a call to malloc in the variable declaration statement.
E.g. for
static void test1(void)
{
char *ptr = malloc(100);
strcpy(ptr, "abcd");
}
static void test2(void)
{
char *ptr;
ptr = malloc(100);
strcpy(ptr, "abcd");
}
only test2 is corrected. Is this because of 1) lack of support
in Julia's answer or 2) a bug?
BR Håkon Løvdal
More information about the Cocci
mailing list