fix mem errors
This commit is contained in:
@@ -21227,13 +21227,18 @@ static JSValue js_cell_text_codepoint (JSContext *ctx, JSValue this_val, int arg
|
||||
int tag = JS_VALUE_GET_TAG (argv[0]);
|
||||
if (tag != JS_TAG_STRING && tag != JS_TAG_STRING_IMM) return JS_NULL;
|
||||
|
||||
JSValue str = JS_ToString (ctx, argv[0]);
|
||||
if (JS_IsException (str)) return str;
|
||||
/* Handle immediate strings directly */
|
||||
if (tag == JS_TAG_STRING_IMM) {
|
||||
int plen = MIST_GetImmediateASCIILen (argv[0]);
|
||||
if (plen == 0) return JS_NULL;
|
||||
uint32_t c = MIST_GetImmediateASCIIChar (argv[0], 0);
|
||||
return JS_NewInt32 (ctx, c);
|
||||
}
|
||||
|
||||
JSText *p = JS_VALUE_GET_STRING (str);
|
||||
/* Heap string */
|
||||
JSText *p = JS_VALUE_GET_STRING (argv[0]);
|
||||
int plen = (int)JSText_len (p);
|
||||
if (plen == 0) {
|
||||
/* str removed - arg not owned */
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
@@ -21246,7 +21251,6 @@ static JSValue js_cell_text_codepoint (JSContext *ctx, JSValue this_val, int arg
|
||||
}
|
||||
}
|
||||
|
||||
/* str removed - arg not owned */
|
||||
return JS_NewInt32 (ctx, c);
|
||||
}
|
||||
|
||||
@@ -23133,7 +23137,8 @@ static JSValue js_cell_fn_apply (JSContext *ctx, JSValue this_val, int argc, JSV
|
||||
|
||||
/* Helper to check if JSValue is a blob */
|
||||
static blob *js_get_blob (JSContext *ctx, JSValue val) {
|
||||
if (JS_VALUE_GET_TAG (val) != JS_TAG_PTR) return NULL;
|
||||
/* Must be a record, not an array or other object type */
|
||||
if (!JS_IsRecord(val)) return NULL;
|
||||
JSRecord *p = JS_VALUE_GET_OBJ (val);
|
||||
if (REC_GET_CLASS_ID(p) != JS_CLASS_BLOB) return NULL;
|
||||
return REC_GET_OPAQUE(p);
|
||||
@@ -24309,7 +24314,10 @@ static JSValue js_cell_length (JSContext *ctx, JSValue this_val, int argc, JSVal
|
||||
int tag = JS_VALUE_GET_TAG (val);
|
||||
|
||||
/* Strings return codepoint count */
|
||||
if (tag == JS_TAG_STRING || tag == JS_TAG_STRING_IMM) {
|
||||
if (tag == JS_TAG_STRING_IMM) {
|
||||
return JS_NewInt32 (ctx, MIST_GetImmediateASCIILen (val));
|
||||
}
|
||||
if (tag == JS_TAG_STRING) {
|
||||
JSText *p = JS_VALUE_GET_STRING (val);
|
||||
return JS_NewInt32 (ctx, (int)JSText_len (p));
|
||||
}
|
||||
|
||||
@@ -297,7 +297,7 @@ static inline double JS_VALUE_GET_FLOAT64 (JSValue v);
|
||||
============================================================ */
|
||||
|
||||
static inline JS_BOOL JS_IsInt (JSValue v) { return (v & 1) == 0; }
|
||||
static inline JS_BOOL JS_IsPtr (JSValue v) { return (v & 3) == JS_TAG_PTR; }
|
||||
static inline JS_BOOL JS_IsPtr (JSValue v) { return (v & 7) == JS_TAG_PTR; }
|
||||
static inline JS_BOOL JS_IsSpecial (JSValue v) { return (v & 3) == JS_TAG_SPECIAL; }
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user