wcap: Prevent fd leak in wcap_decoder_create() fail path
Signed-off-by: Sergi Granell <xerpi.g.12@gmail.com> Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
This commit is contained in:
parent
fec723ef56
commit
597dde5cf6
|
@ -131,6 +131,7 @@ wcap_decoder_create(const char *filename)
|
|||
PROT_READ, MAP_PRIVATE, decoder->fd, 0);
|
||||
if (decoder->map == MAP_FAILED) {
|
||||
fprintf(stderr, "mmap failed\n");
|
||||
close(decoder->fd);
|
||||
free(decoder);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -146,6 +147,7 @@ wcap_decoder_create(const char *filename)
|
|||
frame_size = header->width * header->height * 4;
|
||||
decoder->frame = malloc(frame_size);
|
||||
if (decoder->frame == NULL) {
|
||||
close(decoder->fd);
|
||||
free(decoder);
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue