Skip to content

Commit 1d33d97

Browse files
committed
Correctly handle top-bit-set pointers, fixing Android 11
1 parent d301850 commit 1d33d97

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

java_strings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def __init__(self, DEBUG: bool, target: Target, **kwargs):
115115
class CommonBase {
116116
long ptr;
117117
LinkedList<Object> ptrs_to = new LinkedList();
118-
protected CommonBase(long ptr) { assert ptr > 1024; this.ptr = ptr; }
118+
protected CommonBase(long ptr) { assert ptr < 0 || ptr > 1024; this.ptr = ptr; }
119119
}
120120
"""
121121

@@ -1258,7 +1258,7 @@ def map_function(self, argument_types, c_call_string, method_name, meth_n, retur
12581258
out_java_struct += (info.arg_name)
12591259
out_java_struct += (");\n")
12601260
if return_type_info.java_ty == "long" and return_type_info.java_hu_ty != "long":
1261-
out_java_struct += "\t\tif (ret < 1024) { return null; }\n"
1261+
out_java_struct += "\t\tif (ret >= 0 && ret < 1024) { return null; }\n"
12621262

12631263
if return_type_info.to_hu_conv is not None:
12641264
if not takes_self:

typescript_strings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def __init__(self, DEBUG: bool, target: Target, **kwargs):
120120
void free(void *ptr);
121121
122122
#define MALLOC(a, _) malloc(a)
123-
#define FREE(p) if ((long)(p) > 1024) { free(p); }
123+
#define FREE(p) if ((unsigned long)(p) > 1024) { free(p); }
124124
#define DO_ASSERT(a) (void)(a)
125125
#define CHECK(a)
126126
"""
@@ -174,7 +174,7 @@ def __init__(self, DEBUG: bool, target: Target, **kwargs):
174174
__real_free(it);
175175
}
176176
static void FREE(void* ptr) {
177-
if ((long)ptr < 1024) return; // Rust loves to create pointers to the NULL page for dummys
177+
if ((unsigned long)ptr < 1024) return; // Rust loves to create pointers to the NULL page for dummys
178178
alloc_freed(ptr);
179179
__real_free(ptr);
180180
}

0 commit comments

Comments
 (0)