[TS+Java] Ensure we don't try to add a reference from `null`.
[ldk-java] / typescript_strings.py
index e4d4c3ebec8f06db3b58e7cc4e92e2bad767bb7b..cc7b236315c6be51e1f593b74f3a04be3916fb4f 100644 (file)
@@ -348,7 +348,7 @@ export class CommonBase {
        // In TypeScript, protected means "any subclass can access parent fields on instances of itself"
        // To work around this, we add accessors for other instances' protected fields here.
        protected static add_ref_from(holder: CommonBase, referent: object) {
-               holder.ptrs_to.push(referent);
+               if (holder !== null) { holder.ptrs_to.push(referent); }
        }
        protected static get_ptr_of(o: CommonBase) {
                return o.ptr;