From: Matt Corallo Date: Sat, 9 Oct 2021 23:28:00 +0000 (+0000) Subject: Correctly handle top-bit-set pointers, fixing Android 11 X-Git-Tag: v0.0.101.3^2~3 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=1d33d979ae201a095542e11b0de70516a9f456db;p=ldk-java Correctly handle top-bit-set pointers, fixing Android 11 --- diff --git a/java_strings.py b/java_strings.py index d2054a17..1e7ba997 100644 --- a/java_strings.py +++ b/java_strings.py @@ -115,7 +115,7 @@ import java.util.LinkedList; class CommonBase { long ptr; LinkedList ptrs_to = new LinkedList(); - protected CommonBase(long ptr) { assert ptr > 1024; this.ptr = ptr; } + protected CommonBase(long ptr) { assert ptr < 0 || ptr > 1024; this.ptr = ptr; } } """ @@ -1258,7 +1258,7 @@ import javax.annotation.Nullable; 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" + out_java_struct += "\t\tif (ret >= 0 && ret < 1024) { return null; }\n" if return_type_info.to_hu_conv is not None: if not takes_self: diff --git a/typescript_strings.py b/typescript_strings.py index c097921f..84b27c57 100644 --- a/typescript_strings.py +++ b/typescript_strings.py @@ -120,7 +120,7 @@ void *malloc(size_t size); void free(void *ptr); #define MALLOC(a, _) malloc(a) -#define FREE(p) if ((long)(p) > 1024) { free(p); } +#define FREE(p) if ((unsigned long)(p) > 1024) { free(p); } #define DO_ASSERT(a) (void)(a) #define CHECK(a) """ @@ -174,7 +174,7 @@ static void alloc_freed(void* ptr) { __real_free(it); } static void FREE(void* ptr) { - if ((long)ptr < 1024) return; // Rust loves to create pointers to the NULL page for dummys + if ((unsigned long)ptr < 1024) return; // Rust loves to create pointers to the NULL page for dummys alloc_freed(ptr); __real_free(ptr); }