Skip to content

Commit e998a72

Browse files
committed
lightningd: fix overzealous memleak detection in json_add_datastore.
The lifetime is bound to the response, but memleak gets upset if it sees it. Use the standard take() pattern insteas. ``` lightningd-5 2024-11-28T05:02:27.503Z **BROKEN** lightningd: MEMLEAK: 0x55b58f329338 lightningd-5 2024-11-28T05:02:27.503Z **BROKEN** lightningd: label=common/utils.c:150:char[] lightningd-5 2024-11-28T05:02:27.504Z **BROKEN** lightningd: alloc: lightningd-5 2024-11-28T05:02:27.585Z **BROKEN** lightningd: ccan/ccan/tal/tal.c:488 (tal_alloc_) lightningd-5 2024-11-28T05:02:27.586Z **BROKEN** lightningd: ccan/ccan/tal/tal.c:517 (tal_alloc_arr_) lightningd-5 2024-11-28T05:02:27.586Z **BROKEN** lightningd: ccan/ccan/tal/tal.c:861 (tal_dup_) lightningd-5 2024-11-28T05:02:27.586Z **BROKEN** lightningd: common/utils.c:150 (utf8_str) lightningd-5 2024-11-28T05:02:27.589Z **BROKEN** lightningd: lightningd/datastore.c:23 (json_add_datastore) lightningd-5 2024-11-28T05:02:27.589Z **BROKEN** lightningd: lightningd/datastore.c:205 (json_datastore) lightningd-5 2024-11-28T05:02:27.590Z **BROKEN** lightningd: lightningd/jsonrpc.c:808 (command_exec) lightningd-5 2024-11-28T05:02:27.590Z **BROKEN** lightningd: lightningd/jsonrpc.c:954 (rpc_command_hook_final) lightningd-5 2024-11-28T05:02:27.590Z **BROKEN** lightningd: lightningd/plugin_hook.c:196 (plugin_hook_call_next) lightningd-5 2024-11-28T05:02:27.591Z **BROKEN** lightningd: lightningd/plugin_hook.c:183 (plugin_hook_callback) lightningd-5 2024-11-28T05:02:27.593Z **BROKEN** lightningd: lightningd/plugin.c:663 (plugin_response_handle) lightningd-5 2024-11-28T05:02:27.593Z **BROKEN** lightningd: lightningd/plugin.c:775 (plugin_read_json_one) ``` Signed-off-by: Rusty Russell <[email protected]>
1 parent 5c53ed7 commit e998a72

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lightningd/datastore.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ static void json_add_datastore(struct json_stream *response,
2020

2121
json_add_u64(response, "generation", generation);
2222
json_add_hex(response, "hex", data, tal_bytelen(data));
23-
str = utf8_str(response, data, tal_bytelen(data));
23+
str = utf8_str(NULL, data, tal_bytelen(data));
2424
if (str)
25-
json_add_string(response, "string", str);
25+
json_add_string(response, "string", take(str));
2626
}
2727
}
2828

0 commit comments

Comments
 (0)