diff --git a/sdl/surface.c b/sdl/surface.c index 27443885..d03e9dd8 100644 --- a/sdl/surface.c +++ b/sdl/surface.c @@ -712,12 +712,17 @@ static SDL_Surface* image_to_surface(JSContext *js, JSValue img_obj) JSValue pixels_val = JS_GetPropertyStr(js, img_obj, "pixels"); size_t pixel_len; void *pixel_data = js_get_blob_data(js, &pixel_len, pixels_val, &pixel_data); - - if (blob_result == -1 || blob_result == 0 || !pixel_data) { + + if (pixel_data == -1) { JS_FreeValue(js, pixels_val); return NULL; } + if (!pixel_data) { + JS_FreeValue(js, pixels_val); + return JS_ThrowInternalError(js, "blob was size zero"); + } + // Get pitch (optional) int pitch; JSValue pitch_val = JS_GetPropertyStr(js, img_obj, "pitch"); @@ -947,19 +952,13 @@ JSC_CCALL(surface_convert_generic, // Get source pixels JSValue src_pixels_val = JS_GetPropertyStr(js, argv[0], "pixels"); size_t src_len; - void *src_pixels; - int blob_result = js_get_blob_data(js, &src_len, src_pixels_val, &src_pixels); + void *src_pixels = js_get_blob_data(js, &src_len, src_pixels_val); - if (blob_result == -1) { + if (src_pixels == -1) { JS_FreeValue(js, src_pixels_val); return JS_EXCEPTION; } - if (blob_result == 0 || !src_pixels) { - JS_FreeValue(js, src_pixels_val); - return JS_ThrowTypeError(js, "source pixels must be an ArrayBuffer"); - } - // Get source pitch (optional, calculate if not provided) int src_pitch; JSValue src_pitch_val = JS_GetPropertyStr(js, argv[0], "pitch");