bare-image-resample 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/binding.c +16 -1
- package/package.json +1 -1
- package/prebuilds/android-arm/bare-image-resample.bare +0 -0
- package/prebuilds/android-arm64/bare-image-resample.bare +0 -0
- package/prebuilds/android-ia32/bare-image-resample.bare +0 -0
- package/prebuilds/android-x64/bare-image-resample.bare +0 -0
- package/prebuilds/darwin-arm64/bare-image-resample.bare +0 -0
- package/prebuilds/darwin-x64/bare-image-resample.bare +0 -0
- package/prebuilds/ios-arm64/bare-image-resample.bare +0 -0
- package/prebuilds/ios-arm64-simulator/bare-image-resample.bare +0 -0
- package/prebuilds/ios-x64-simulator/bare-image-resample.bare +0 -0
- package/prebuilds/linux-arm64/bare-image-resample.bare +0 -0
- package/prebuilds/linux-x64/bare-image-resample.bare +0 -0
- package/prebuilds/win32-arm64/bare-image-resample.bare +0 -0
- package/prebuilds/win32-x64/bare-image-resample.bare +0 -0
package/binding.c
CHANGED
|
@@ -13,6 +13,10 @@
|
|
|
13
13
|
// for, and it is how both the source and the target buffers are laid out.
|
|
14
14
|
static const int64_t BYTES_PER_PIXEL = 4;
|
|
15
15
|
|
|
16
|
+
// Cap the resampled pixel count to keep the requested dimensions from reaching
|
|
17
|
+
// the allocator. 256 Mpx at 4 bytes per pixel covers up to a 16384x16384 image.
|
|
18
|
+
#define BARE_IMAGE_RESAMPLE_MAX_PIXELS (1ull << 28)
|
|
19
|
+
|
|
16
20
|
static js_value_t *
|
|
17
21
|
bare_image_resample_resize(js_env_t *env, js_callback_info_t *info) {
|
|
18
22
|
int err;
|
|
@@ -73,6 +77,16 @@ bare_image_resample_resize(js_env_t *env, js_callback_info_t *info) {
|
|
|
73
77
|
return NULL;
|
|
74
78
|
}
|
|
75
79
|
|
|
80
|
+
if (
|
|
81
|
+
(uint64_t) source_width * (uint64_t) source_height > BARE_IMAGE_RESAMPLE_MAX_PIXELS ||
|
|
82
|
+
(uint64_t) target_width * (uint64_t) target_height > BARE_IMAGE_RESAMPLE_MAX_PIXELS
|
|
83
|
+
) {
|
|
84
|
+
err = js_throw_error(env, NULL, "Image dimensions exceed maximum");
|
|
85
|
+
assert(err == 0);
|
|
86
|
+
|
|
87
|
+
return NULL;
|
|
88
|
+
}
|
|
89
|
+
|
|
76
90
|
uint64_t target_len = (uint64_t) target_width * (uint64_t) target_height * BYTES_PER_PIXEL;
|
|
77
91
|
|
|
78
92
|
if (target_len > SIZE_MAX) {
|
|
@@ -86,7 +100,8 @@ bare_image_resample_resize(js_env_t *env, js_callback_info_t *info) {
|
|
|
86
100
|
|
|
87
101
|
uint8_t *target;
|
|
88
102
|
err = js_create_unsafe_arraybuffer(env, (size_t) target_len, (void **) &target, &result);
|
|
89
|
-
|
|
103
|
+
|
|
104
|
+
if (err < 0) return NULL;
|
|
90
105
|
|
|
91
106
|
stbir_resize(
|
|
92
107
|
source,
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|