Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions contrib/libtests/pnggetset.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,10 @@ test_text_roundtrip(void)
text_entries[i].key = (png_charp)keys[i];
text_entries[i].text = (png_charp)vals[i];
}
#ifdef PNG_iTXt_SUPPORTED
/* Exercise the documented NULL language pointers for iTXt. */
text_entries[TEXT_COUNT - 1].compression = PNG_ITXT_COMPRESSION_NONE;
#endif
png_set_text(png_ptr, info_ptr, text_entries, TEXT_COUNT);

/* Get the internal pointer and feed it straight back (append). */
Expand Down
6 changes: 4 additions & 2 deletions pngset.c
Original file line number Diff line number Diff line change
Expand Up @@ -1105,10 +1105,12 @@ png_set_text_2(const png_struct *png_ptr, png_info *info_ptr,
if (text_ptr[i].compression > 0)
{
textp->lang = textp->key + key_len + 1;
memcpy(textp->lang, text_ptr[i].lang, lang_len);
if (lang_len != 0)
memcpy(textp->lang, text_ptr[i].lang, lang_len);
*(textp->lang + lang_len) = '\0';
textp->lang_key = textp->lang + lang_len + 1;
memcpy(textp->lang_key, text_ptr[i].lang_key, lang_key_len);
if (lang_key_len != 0)
memcpy(textp->lang_key, text_ptr[i].lang_key, lang_key_len);
*(textp->lang_key + lang_key_len) = '\0';
textp->text = textp->lang_key + lang_key_len + 1;
}
Expand Down