Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert pointers to references in jpeg_segment_find() #1608

Closed
wants to merge 1 commit into from
Closed
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
8 changes: 4 additions & 4 deletions src/exif-common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -977,10 +977,10 @@ gboolean exif_jpeg_parse_color(ExifData *exif, guchar *data, guint size)
*/

while (jpeg_segment_find(data + seg_offset + seg_length,
size - seg_offset - seg_length,
JPEG_MARKER_APP2,
"ICC_PROFILE\x00", 12,
&seg_offset, &seg_length))
size - seg_offset - seg_length,
JPEG_MARKER_APP2,
"ICC_PROFILE\x00", 12,
seg_offset, seg_length))
{
guchar chunk_num;
guchar chunk_tot;
Expand Down
8 changes: 4 additions & 4 deletions src/exif.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1069,8 +1069,6 @@ static gint exif_jpeg_parse(ExifData *exif,
guchar *data, guint size,
ExifMarker *list)
{
guint seg_offset = 0;
guint seg_length = 0;
gint res = -1;

if (size < 4 ||
Expand All @@ -1079,9 +1077,11 @@ static gint exif_jpeg_parse(ExifData *exif,
return -2;
}

guint seg_offset = 0;
guint seg_length = 0;
if (jpeg_segment_find(data, size, JPEG_MARKER_APP1,
"Exif\x00\x00", 6,
&seg_offset, &seg_length))
"Exif\x00\x00", 6,
seg_offset, seg_length))
{
res = exif_tiff_parse(exif, data + seg_offset + 6, seg_length - 6, list);
}
Expand Down
12 changes: 6 additions & 6 deletions src/jpeg-parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ gboolean is_jpeg_container(const guchar *data, guint size)
}

gboolean jpeg_segment_find(const guchar *data, guint size,
guchar app_marker, const gchar *magic, guint magic_len,
guint *seg_offset, guint *seg_length)
guchar app_marker, const gchar *magic, guint magic_len,
guint &seg_offset, guint &seg_length)
{
guchar marker = 0;
guint offset = 0;
Expand All @@ -267,8 +267,8 @@ gboolean jpeg_segment_find(const guchar *data, guint size,
length >= 4 + magic_len &&
memcmp(data + offset + 4, magic, magic_len) == 0)
{
*seg_offset = offset + 4;
*seg_length = length - 4;
seg_offset = offset + 4;
seg_length = length - 4;
return TRUE;
}
}
Expand All @@ -280,7 +280,7 @@ MPOData jpeg_get_mpo_data(const guchar *data, guint size)
{
guint seg_offset;
guint seg_size;
if (!jpeg_segment_find(data, size, JPEG_MARKER_APP2, "MPF\x00", 4, &seg_offset, &seg_size) || seg_size <= 16) return {};
if (!jpeg_segment_find(data, size, JPEG_MARKER_APP2, "MPF\x00", 4, seg_offset, seg_size) || seg_size <= 16) return {};

DEBUG_1("mpo signature found at %x", seg_offset);
seg_offset += 4;
Expand Down Expand Up @@ -319,7 +319,7 @@ MPOData jpeg_get_mpo_data(const guchar *data, guint size)
}
else
{
if (!jpeg_segment_find(data + mpo.images[i].offset, mpo.images[i].length, JPEG_MARKER_APP2, "MPF\x00", 4, &seg_offset, &seg_size) || seg_size <=16)
if (!jpeg_segment_find(data + mpo.images[i].offset, mpo.images[i].length, JPEG_MARKER_APP2, "MPF\x00", 4, seg_offset, seg_size) || seg_size <= 16)
{
DEBUG_1("MPO image %u: MPO signature not found", i);
continue;
Expand Down
4 changes: 2 additions & 2 deletions src/jpeg-parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
gboolean is_jpeg_container(const guchar *data, guint size);

gboolean jpeg_segment_find(const guchar *data, guint size,
guchar app_marker, const gchar *magic, guint magic_len,
guint *seg_offset, guint *seg_length);
guchar app_marker, const gchar *magic, guint magic_len,
guint &seg_offset, guint &seg_length);


struct MPOEntry {
Expand Down
Loading