diff --git a/plugins/excel/ms-excel-read.c b/plugins/excel/ms-excel-read.c
index 82255ea..41b8295 100644
--- a/plugins/excel/ms-excel-read.c
+++ b/plugins/excel/ms-excel-read.c
@@ -4442,6 +4442,8 @@ excel_read_IMDATA (BiffQuery *q, gboolean keep_image)
 	format = GSF_LE_GET_GUINT16 (q->data);
 	image_len = GSF_LE_GET_GUINT32 (q->data + 4);
 
+	XL_CHECK_CONDITION_VAL (q->length >= image_len, NULL);
+
 	switch (format) {
 	case 0x2: break;	/* Windows metafile/Mac pict */
 	case 0x9:		/* OS/2 BMP sans header */
