summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2014-02-23 01:28:29 +0100
committerClifford Wolf <clifford@clifford.at>2014-02-23 01:28:29 +0100
commitb76528d8a557dc324b1dfaa366e2b620795f582d (patch)
tree32003ff303326e6b830a82961e835c8150245eb2 /kernel
parentf8c9143b2b232e2f22e6cfbf9c431b2a1b756afa (diff)
Fixed small memory leak in Pass::call()
Diffstat (limited to 'kernel')
-rw-r--r--kernel/register.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/kernel/register.cc b/kernel/register.cc
index 32570966..ee14ffba 100644
--- a/kernel/register.cc
+++ b/kernel/register.cc
@@ -133,8 +133,10 @@ void Pass::call(RTLIL::Design *design, std::string command)
std::vector<std::string> 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)) {