Skip to content

Commit 173d1b3

Browse files
committed
gpujpeg_image_calculate_size: add assertion
he values may be invalid if struct uninitialized **may** fail: `gpujpegtool -e 16384x1024.p_u8.tst out.jpg` tst pattern doesn't initialize the gpujpeg_image_parameters, namely with_padding), which occurs since the commit c35b498 (2025-05-07).
1 parent 13601ed commit 173d1b3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/gpujpeg_common.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,6 +1155,10 @@ gpujpeg_coder_deinit(struct gpujpeg_coder* coder)
11551155
size_t
11561156
gpujpeg_image_calculate_size(struct gpujpeg_image_parameters* param)
11571157
{
1158+
assert(param->width > 0 && param->height > 0);
1159+
assert(param->width <= 65535 && param->height <= 65535);
1160+
assert(param->width_padding >= 0);
1161+
assert(param->width_padding < 100000); // safety check - 100k chosen arbitrarily
11581162
int bpp = gpujpeg_pixel_format_get_unit_size(param->pixel_format);
11591163
if (bpp != 0) {
11601164
return ((size_t) param->width + param->width_padding) * param->height * bpp;

0 commit comments

Comments
 (0)