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

@@ -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);