mirror of https://github.com/YosysHQ/yosys.git
Fixed small memory leak in Pass::call()
This commit is contained in:
parent
f8c9143b2b
commit
b76528d8a5
|
@ -133,8 +133,10 @@ void Pass::call(RTLIL::Design *design, std::string command)
|
||||||
std::vector<std::string> args;
|
std::vector<std::string> args;
|
||||||
char *s = strdup(command.c_str()), *sstart = s, *saveptr;
|
char *s = strdup(command.c_str()), *sstart = s, *saveptr;
|
||||||
s += strspn(s, " \t\r\n");
|
s += strspn(s, " \t\r\n");
|
||||||
if (*s == 0 || *s == '#')
|
if (*s == 0 || *s == '#') {
|
||||||
|
free(sstart);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
if (*s == '!') {
|
if (*s == '!') {
|
||||||
for (s++; *s == ' ' || *s == '\t'; s++) { }
|
for (s++; *s == ' ' || *s == '\t'; s++) { }
|
||||||
char *p = s + strlen(s) - 1;
|
char *p = s + strlen(s) - 1;
|
||||||
|
@ -144,6 +146,7 @@ void Pass::call(RTLIL::Design *design, std::string command)
|
||||||
int retCode = system(s);
|
int retCode = system(s);
|
||||||
if (retCode != 0)
|
if (retCode != 0)
|
||||||
log_cmd_error("Shell command returned error code %d.\n", retCode);
|
log_cmd_error("Shell command returned error code %d.\n", retCode);
|
||||||
|
free(sstart);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (char *p = strtok_r(s, " \t\r\n", &saveptr); p; p = strtok_r(NULL, " \t\r\n", &saveptr)) {
|
for (char *p = strtok_r(s, " \t\r\n", &saveptr); p; p = strtok_r(NULL, " \t\r\n", &saveptr)) {
|
||||||
|
|
Loading…
Reference in New Issue