From: Clifford Wolf Date: Sun, 23 Feb 2014 00:28:29 +0000 (+0100) Subject: Fixed small memory leak in Pass::call() X-Git-Tag: yosys-0.3.0~109 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b76528d8a557dc324b1dfaa366e2b620795f582d;p=yosys.git Fixed small memory leak in Pass::call() --- diff --git a/kernel/register.cc b/kernel/register.cc index 325709664..ee14ffbad 100644 --- a/kernel/register.cc +++ b/kernel/register.cc @@ -133,8 +133,10 @@ void Pass::call(RTLIL::Design *design, std::string command) std::vector args; char *s = strdup(command.c_str()), *sstart = s, *saveptr; s += strspn(s, " \t\r\n"); - if (*s == 0 || *s == '#') + if (*s == 0 || *s == '#') { + free(sstart); return; + } if (*s == '!') { for (s++; *s == ' ' || *s == '\t'; s++) { } char *p = s + strlen(s) - 1; @@ -144,6 +146,7 @@ void Pass::call(RTLIL::Design *design, std::string command) int retCode = system(s); if (retCode != 0) log_cmd_error("Shell command returned error code %d.\n", retCode); + free(sstart); return; } for (char *p = strtok_r(s, " \t\r\n", &saveptr); p; p = strtok_r(NULL, " \t\r\n", &saveptr)) {