Avoid segfault on CLI command "dev-memleak" when $LIGHTNINGD_DEV_MEMLEAK is not set

This commit is contained in:
practicalswift 2018-01-14 22:58:22 +01:00 committed by Rusty Russell
parent 44836ef509
commit 447afa923d
1 changed files with 3 additions and 1 deletions

View File

@ -144,9 +144,11 @@ static void json_memleak(struct command *cmd,
{
struct json_result *response = new_json_result(cmd);
if (!getenv("LIGHTNINGD_DEV_MEMLEAK"))
if (!getenv("LIGHTNINGD_DEV_MEMLEAK")) {
command_fail(cmd,
"Leak detection needs $LIGHTNINGD_DEV_MEMLEAK");
return;
}
json_object_start(response, NULL);
scan_mem(cmd, response, cmd->ld);