json-rpc: translate NULL into "null" instead of "(null)".#1118
Conversation
|
|
|
I believe this is the point which we should modify: lightning/lightningd/jsonrpc.c Lines 687 to 689 in 73cda2f It should be Then inside both |
|
Agreed: that seems to be somewhat less ugly than what I made. Could we somehow ensure that NULL is never passed to tal_fmt through another route? I find it scary to have stumbled upon something that is actually undefined behavior. |
|
Wait for @practicalswift to do regular undefined behavior checking has always been my personal technique, hahaha. |
|
Was about to suggest the same as @ZmnSCPxj : let's kill the root cause, and assert() that it never happens again. |
|
On a more serious note, @bitonic-cjp: undefined behavior is mostly caught by code review and sometimes by automated tools that scan for them, and |
…ver receive NULL arguments. Pass "null" instead, where needed.
|
I did what ZmnSCPxj said; now I'm checking other tal_fmt calls. |
|
ACK 59b7f9e |
| const char *id, | ||
| const struct json_result *result) | ||
| { | ||
| assert(id != NULL); |
There was a problem hiding this comment.
Nit: Make sure the indentation matches the surrounding code. Same below.
There was a problem hiding this comment.
Agreed; I already discovered this myself, and was going to fix it.
|
ACK 500db24 |
It turns out that #957 is insufficient to solve #908 . This fix is needed to really say "id": null instead of "id": (null).
This is probably an incomplete fix: it would be better to make sure that all cases of NULL are translated into "null". However, I didn't want to touch the tal_fmt implementation. What would be a good approach? make a json_fmt wrapper around tal_fmt to do this? I didn't do this yet: since I'm not too familiar with the code base yet, I didn't want to make too large changes without any guidance.