summaryrefslogtreecommitdiff
path: root/jbig2dec/jbig2_segment.c
diff options
context:
space:
mode:
Diffstat (limited to 'jbig2dec/jbig2_segment.c')
-rw-r--r--jbig2dec/jbig2_segment.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/jbig2dec/jbig2_segment.c b/jbig2dec/jbig2_segment.c
index 1ae3e2199..044238341 100644
--- a/jbig2dec/jbig2_segment.c
+++ b/jbig2dec/jbig2_segment.c
@@ -57,12 +57,17 @@ jbig2_parse_segment_header(Jbig2Ctx *ctx, uint8_t *buf, size_t buf_size, size_t
result = jbig2_new(ctx, Jbig2Segment, 1);
if (result == NULL) {
- jbig2_error(ctx, JBIG2_SEVERITY_FATAL, -1, "failed to allocate segment");
+ jbig2_error(ctx, JBIG2_SEVERITY_FATAL, JBIG2_UNKNOWN_SEGMENT_NUMBER, "failed to allocate segment");
return NULL;
}
/* 7.2.2 */
result->number = jbig2_get_uint32(buf);
+ if (result->number == JBIG2_UNKNOWN_SEGMENT_NUMBER) {
+ jbig2_error(ctx, JBIG2_SEVERITY_FATAL, JBIG2_UNKNOWN_SEGMENT_NUMBER, "segment number too large");
+ jbig2_free(ctx->allocator, result);
+ return NULL;
+ }
/* 7.2.3 */
result->flags = buf[4];