From 4b5a8fbe74515a9c521c7104190f9ed3e5d90832 Mon Sep 17 00:00:00 2001 From: Jeff Muizelaar Date: Fri, 12 Jun 2009 14:38:34 -0400 Subject: [PATCH] Bug 497363. qcms: Fix a memory leak when fread() fails. r=joedrew Fixes a possible leak in qcms_profile_from_file() when fread() can't read the entire profile. --- gfx/qcms/iccread.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gfx/qcms/iccread.c b/gfx/qcms/iccread.c index 89167216dd3..22a52ccc345 100644 --- a/gfx/qcms/iccread.c +++ b/gfx/qcms/iccread.c @@ -765,8 +765,10 @@ qcms_profile* qcms_profile_from_file(FILE *file) /* read the rest profile */ read_length = fread((unsigned char*)data + sizeof(length_be), 1, remaining_length, file); - if (read_length != remaining_length) + if (read_length != remaining_length) { + free(data); return INVALID_PROFILE; + } profile = qcms_profile_from_memory(data, length); free(data);