Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#2 memory allocation not proper...

open
nobody
None
5
2007-06-21
2007-06-21
Anonymous
No

In the file routing.c , in the function set_route
request variable is declared as double pointer and then without alloting the memory for the pointer to the array it started intialising it..

char **request;
for (j = 0; j < 10; j++)
request[j] = (char *) malloc (128 * sizeof(char));
request[0] = "net";
request[1] = dest;
request[2] = "gw";
request[3] = gw;
//request[4] = "metric";
//sprintf (request[5], "%d", metric);
request[6] = "netmask";
request[7] = mask;
request[8] = "dev";
request[9] = iface;

And i think there is no need of the foor loop here and instead of that we shud have...

request=(char **)malloc(10*sizeof(char *));

please comment.....

Discussion