fix fd.c bugs

This commit is contained in:
2026-02-10 14:21:49 -06:00
parent 54673e4a04
commit fe5dc6ecc9
10 changed files with 815 additions and 794 deletions

View File

@@ -3125,13 +3125,18 @@ JSValue JS_CallRegisterVM(JSContext *ctx, JSCodeRegister *code,
goto disrupt;
} else {
/* Record method call: get property, call with this=obj */
if (JS_IsNull(frame->slots[base])) {
JS_ThrowTypeError(ctx, "cannot read properties of null");
JS_PopGCRef(ctx, &key_ref);
goto disrupt;
}
JSValue method = JS_GetProperty(ctx, frame->slots[base], key_ref.val);
frame = (JSFrameRegister *)JS_VALUE_GET_PTR(frame_ref.val);
if (JS_IsException(method)) { JS_PopGCRef(ctx, &key_ref); goto disrupt; }
if (!JS_IsFunction(method)) {
frame->slots[base] = JS_NULL;
JS_ThrowTypeError(ctx, "not a function");
JS_PopGCRef(ctx, &key_ref);
break;
goto disrupt;
}
JSFunction *fn = JS_VALUE_GET_FUNCTION(method);
if (fn->kind == JS_FUNC_KIND_C) {

View File

@@ -9923,7 +9923,7 @@ static JSValue js_blob_constructor (JSContext *ctx, JSValue this_val, int argc,
}
}
/* blob(blob, from, to) - copy from another blob */
else if (argc >= 1 && JS_IsObject (argv[0])) {
else if (argc >= 1 && JS_IsObject (argv[0]) && !JS_IsText (argv[0])) {
blob *src = js_get_blob (ctx, argv[0]);
if (!src)
return JS_ThrowTypeError (ctx,
@@ -9941,9 +9941,7 @@ static JSValue js_blob_constructor (JSContext *ctx, JSValue this_val, int argc,
bd = blob_new_from_blob (src, (size_t)from, (size_t)to);
}
/* blob(text) - create blob from UTF-8 string */
else if (argc == 1
&& (JS_VALUE_GET_TAG (argv[0]) == JS_TAG_STRING
|| JS_VALUE_GET_TAG (argv[0]) == JS_TAG_STRING_IMM)) {
else if (argc == 1 && JS_IsText (argv[0])) {
const char *str = JS_ToCString (ctx, argv[0]);
if (!str) return JS_EXCEPTION;
size_t len = strlen (str);