This error case can only be triggered by gzread returning 0 (and having
not read anything), so move it there.
Coverity-ID:
1056076
Signed-off-by: Matthew Daley <mattjd@gmail.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
image = NULL;
goto out;
case 0: /* EOF */
+ if ( *size == 0 )
+ {
+ PERROR("Could not read kernel image");
+ free(image);
+ image = NULL;
+ }
goto out;
default:
*size += bytes;
#undef CHUNK
out:
- if ( *size == 0 )
- {
- PERROR("Could not read kernel image");
- free(image);
- image = NULL;
- }
- else if ( image )
+ if ( image )
{
/* Shrink allocation to fit image. */
tmp = realloc(image, *size);