mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-13 04:28:18 +00:00
Fix readline/editline memory leak
This commit is contained in:
parent
8367f06188
commit
2ab7d1d0c8
|
@ -1353,8 +1353,12 @@ void shell(RTLIL::Design *design)
|
||||||
if ((command = fgets(command_buffer, 4096, stdin)) == NULL)
|
if ((command = fgets(command_buffer, 4096, stdin)) == NULL)
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
if (command[strspn(command, " \t\r\n")] == 0)
|
if (command[strspn(command, " \t\r\n")] == 0) {
|
||||||
|
#if defined(YOSYS_ENABLE_READLINE) || defined(YOSYS_ENABLE_EDITLINE)
|
||||||
|
free(command);
|
||||||
|
#endif
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
#if defined(YOSYS_ENABLE_READLINE) || defined(YOSYS_ENABLE_EDITLINE)
|
#if defined(YOSYS_ENABLE_READLINE) || defined(YOSYS_ENABLE_EDITLINE)
|
||||||
add_history(command);
|
add_history(command);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1376,10 +1380,17 @@ void shell(RTLIL::Design *design)
|
||||||
log_reset_stack();
|
log_reset_stack();
|
||||||
}
|
}
|
||||||
design->check();
|
design->check();
|
||||||
|
#if defined(YOSYS_ENABLE_READLINE) || defined(YOSYS_ENABLE_EDITLINE)
|
||||||
|
if (command)
|
||||||
|
free(command);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (command == NULL)
|
if (command == NULL)
|
||||||
printf("exit\n");
|
printf("exit\n");
|
||||||
|
#if defined(YOSYS_ENABLE_READLINE) || defined(YOSYS_ENABLE_EDITLINE)
|
||||||
|
else
|
||||||
|
free(command);
|
||||||
|
#endif
|
||||||
recursion_counter--;
|
recursion_counter--;
|
||||||
log_cmd_error_throw = false;
|
log_cmd_error_throw = false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue