Skip to content

Commit 4568b2b

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 86706cd commit 4568b2b

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
@@ -701,7 +701,7 @@ def set_null_skip_free(self, var):
701701
return var + ".ptr" + " = 0;"
702702

703703
def add_ref(self, holder, referent):
704-
return holder + ".ptrs_to.add(" + referent + ")"
704+
return "if (" + holder + " != null) { " + holder + ".ptrs_to.add(" + referent + "); }"
705705

706706
def fully_qualified_hu_ty_path(self, ty):
707707
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
@@ -341,7 +341,7 @@ def __init__(self, DEBUG: bool, target: Target, outdir: str, **kwargs):
341341
// In TypeScript, protected means "any subclass can access parent fields on instances of itself"
342342
// To work around this, we add accessors for other instances' protected fields here.
343343
protected static add_ref_from(holder: CommonBase, referent: object) {
344-
holder.ptrs_to.push(referent);
344+
if (holder !== null) { holder.ptrs_to.push(referent); }
345345
}
346346
protected static get_ptr_of(o: CommonBase) {
347347
return o.ptr;

0 commit comments

Comments
 (0)