fix string leak with blob write_text

This commit is contained in:
2025-06-06 13:58:46 -05:00
parent e0595de71a
commit 72beed7177

View File

@@ -199,9 +199,12 @@ static JSValue js_blob_write_text(JSContext *ctx, JSValueConst this_val,
// Handle number or single character string
const char *str = JS_ToCString(ctx, argv[0]);
if (blob_write_text(bd, str) < 0)
if (blob_write_text(bd, str) < 0) {
JS_FreeCString(ctx,str);
return JS_ThrowTypeError(ctx, "write_kim: cannot write to stone blob or OOM");
}
JS_FreeCString(ctx,str);
return JS_UNDEFINED;
}