Skip to content

Commit 18e551b

Browse files
committed
Exif writer: fix writing header without custom tags
custom_tags.count is referenced but if no custom tags defined, the pointer was NULL.
1 parent a0a5b51 commit 18e551b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/gpujpeg_exif.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ gpujpeg_write_ifd(struct gpujpeg_writer* writer, const uint8_t* start, size_t co
302302
* from tags remove the items that are overriden by custom_tags
303303
*/
304304
static size_t
305-
remove_overriden(size_t count, struct tag_value tags[], const struct custom_exif_tags* custom_tags)
305+
remove_overriden(size_t count, struct tag_value tags[static count], const struct custom_exif_tags custom_tags[static 1])
306306
{
307307
for ( unsigned i = 0; i < custom_tags->count; ++i ) {
308308
for ( unsigned j = 0; j < count; ++j ) {
@@ -334,7 +334,7 @@ gpujpeg_write_0th(struct gpujpeg_encoder* encoder, const uint8_t* start)
334334
{ETIFF_EXIF_IFD_POINTER, {0} }, // value will be set later
335335
};
336336
size_t tag_count = ARR_SIZE(tags);
337-
const struct custom_exif_tags* custom_tags = NULL;
337+
const struct custom_exif_tags* custom_tags = &(struct custom_exif_tags){0};
338338
if (encoder->writer->exif_tags != NULL) {
339339
custom_tags = &encoder->writer->exif_tags->tags[CT_TIFF];
340340
tag_count = remove_overriden(tag_count, tags, custom_tags);
@@ -354,7 +354,7 @@ static void gpujpeg_write_exif_ifd(struct gpujpeg_encoder* encoder, const uint8_
354354
{EEXIF_PIXEL_Y_DIMENSION, {.uvalue = (uint32_t[]){encoder->coder.param_image.height}}},
355355
};
356356
size_t tag_count = ARR_SIZE(tags);
357-
const struct custom_exif_tags* custom_tags = NULL;
357+
const struct custom_exif_tags* custom_tags = &(struct custom_exif_tags){0};
358358
if (encoder->writer->exif_tags != NULL) {
359359
custom_tags = &encoder->writer->exif_tags->tags[CT_EXIF];
360360
tag_count = remove_overriden(tag_count, tags, custom_tags);

0 commit comments

Comments
 (0)