Fix possible buffer overflow.
This commit is contained in:
parent
f147cf9c61
commit
b25df08c99
|
|
@ -80,15 +80,16 @@ __inline__ static void draw_module_declarations(ivl_design_t des)
|
|||
const char*cp = ivl_design_flag(des, "VPI_MODULE_LIST");
|
||||
|
||||
while (*cp) {
|
||||
char buffer[128];
|
||||
const char*comma = strchr(cp, ',');
|
||||
|
||||
if (comma == 0)
|
||||
comma = cp + strlen(cp);
|
||||
|
||||
char*buffer = malloc(comma - cp + 1);
|
||||
strncpy(buffer, cp, comma-cp);
|
||||
buffer[comma-cp] = 0;
|
||||
fprintf(vvp_out, ":vpi_module \"%s\";\n", buffer);
|
||||
free(buffer);
|
||||
|
||||
cp = comma;
|
||||
if (*cp) cp += 1;
|
||||
|
|
|
|||
Loading…
Reference in New Issue