Skip to content

Commit 3050524

Browse files
committed
[TS+Java] Ensure we don't try to add a reference from null.
At least in `Event::PaymentPathFailed` if we try to map an event with no `retry` we'll hit a `NullPointerException` as we'll try to add a reference from the `null` retry back to the `Event` itself. The simple fix is to simply exhaustively check for `null` before adding references everywhere.
1 parent d4ebc84 commit 3050524

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

java_strings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ def set_null_skip_free(self, var):
704704
return var + ".ptr" + " = 0;"
705705

706706
def add_ref(self, holder, referent):
707-
return holder + ".ptrs_to.add(" + referent + ")"
707+
return "if (" + holder + " != null) { " + holder + ".ptrs_to.add(" + referent + "); }"
708708

709709
def fully_qualified_hu_ty_path(self, ty):
710710
if ty.java_fn_ty_arg.startswith("L") and ty.java_fn_ty_arg.endswith(";"):

typescript_strings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ def __init__(self, DEBUG: bool, target: Target, outdir: str, **kwargs):
348348
// In TypeScript, protected means "any subclass can access parent fields on instances of itself"
349349
// To work around this, we add accessors for other instances' protected fields here.
350350
protected static add_ref_from(holder: CommonBase, referent: object) {
351-
holder.ptrs_to.push(referent);
351+
if (holder !== null) { holder.ptrs_to.push(referent); }
352352
}
353353
protected static get_ptr_of(o: CommonBase) {
354354
return o.ptr;

0 commit comments

Comments
 (0)