]> git.bitcoin.ninja Git - ldk-java/commitdiff
Correctly handle null pointers returned from Rust representing None
authorMatt Corallo <git@bluematt.me>
Thu, 5 Aug 2021 03:18:28 +0000 (03:18 +0000)
committerMatt Corallo <git@bluematt.me>
Thu, 5 Aug 2021 03:18:28 +0000 (03:18 +0000)
java_strings.py

index f6bf763d9695bef6b0ae028da82f0f0b8c77a01c..d4931cd912038295c89ab63ce11f0ffdbe9e35e7 100644 (file)
@@ -106,7 +106,7 @@ import java.util.LinkedList;
 class CommonBase {
        long ptr;
        LinkedList<Object> ptrs_to = new LinkedList();
-       protected CommonBase(long ptr) { this.ptr = ptr; }
+       protected CommonBase(long ptr) { assert ptr > 1024; this.ptr = ptr; }
 }
 """
 
@@ -1226,6 +1226,9 @@ import java.util.Arrays;
                 else:
                     out_java_struct += (info.arg_name)
             out_java_struct += (");\n")
+            if return_type_info.java_ty == "long" and return_type_info.java_hu_ty != "long":
+                out_java_struct += "\t\tif (ret < 1024) { return null; }\n"
+
             if return_type_info.to_hu_conv is not None:
                 if not takes_self:
                     out_java_struct += ("\t\t" + return_type_info.to_hu_conv.replace("\n", "\n\t\t").replace("this",