Browse Source

pytest: fix temporary memleak found by test_misc.py::test_htlc_out_timeout

```
E           Global errors:
E            - Node /tmp/ltests-o5mr9txw/test_htlc_out_timeout_1/lightning-1/ has memory leaks: [
E               {
E                   "backtrace": [
E                       "ccan/ccan/tal/tal.c:442 (tal_alloc_)",
E                       "ccan/ccan/tal/tal.c:471 (tal_alloc_arr_)",
E                       "common/json_helpers.c:182 (json_add_address)",
E                       "common/json_helpers.c:242 (json_add_address_internal)",
E                       "lightningd/peer_control.c:1659 (json_getinfo)",
E                       "lightningd/jsonrpc.c:598 (command_exec)",
E                       "lightningd/jsonrpc.c:708 (rpc_command_hook_callback)",
E                       "lightningd/plugin_hook.c:278 (plugin_hook_call_)",
E                       "lightningd/jsonrpc.c:785 (plugin_hook_call_rpc_command)",
E                       "lightningd/jsonrpc.c:864 (parse_request)",
E                       "lightningd/jsonrpc.c:954 (read_json)",
E                       "ccan/ccan/io/io.c:59 (next_plan)",
E                       "ccan/ccan/io/io.c:435 (io_do_always)",
E                       "ccan/ccan/io/poll.c:300 (handle_always)",
E                       "ccan/ccan/io/poll.c:377 (io_loop)",
E                       "lightningd/io_loop_with_timers.c:24 (io_loop_with_timers)",
E                       "lightningd/lightningd.c:1013 (main)"
E                   ],
E                   "label": "common/json_helpers.c:182:char[]",
E                   "parents": [
E                       "common/json_stream.c:29:struct json_stream",
E                       "ccan/ccan/io/io.c:91:struct io_conn",
E                       "lightningd/lightningd.c:116:struct lightningd"
E                   ],
E                   "value": "0x555e17b303e8"
E               }
E           ]
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
bump-pyln-proto
Rusty Russell 4 years ago
parent
commit
fc2fa56b55
  1. 3
      common/json_helpers.c

3
common/json_helpers.c

@ -179,13 +179,14 @@ void json_add_address(struct json_stream *response, const char *fieldname,
const struct wireaddr *addr)
{
json_object_start(response, fieldname);
char *addrstr = tal_arr(response, char, INET6_ADDRSTRLEN);
if (addr->type == ADDR_TYPE_IPV4) {
char addrstr[INET_ADDRSTRLEN];
inet_ntop(AF_INET, addr->addr, addrstr, INET_ADDRSTRLEN);
json_add_string(response, "type", "ipv4");
json_add_string(response, "address", addrstr);
json_add_num(response, "port", addr->port);
} else if (addr->type == ADDR_TYPE_IPV6) {
char addrstr[INET6_ADDRSTRLEN];
inet_ntop(AF_INET6, addr->addr, addrstr, INET6_ADDRSTRLEN);
json_add_string(response, "type", "ipv6");
json_add_string(response, "address", addrstr);

Loading…
Cancel
Save