diff options
| author | Eduardo Barretto <edusbarretto@gmail.com> | 2020-04-16 19:09:40 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-17 00:09:40 +0200 |
| commit | 040e142288e90c9c2d46d25d0a27f828f968bb93 (patch) | |
| tree | 48d747bb1bcdfa12c4b1cc3105e136e0fbfdb868 /src/lib/openmj2 | |
| parent | 221a801a97a3ea968a311f7905c18a1eb7f034c4 (diff) | |
jp3d/jpwl/mj2/jpip: Fix resource leaks (#1226)
This issues were found by cppcheck and coverity.
Diffstat (limited to 'src/lib/openmj2')
| -rw-r--r-- | src/lib/openmj2/mj2.c | 8 | ||||
| -rw-r--r-- | src/lib/openmj2/mj2_convert.c | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/lib/openmj2/mj2.c b/src/lib/openmj2/mj2.c index 8e036f18..3cbf83f5 100644 --- a/src/lib/openmj2/mj2.c +++ b/src/lib/openmj2/mj2.c @@ -2822,16 +2822,24 @@ int OPJ_CALLCONV mj2_read_struct(FILE *file, opj_mj2_t *movie) fseek(file, foffset, SEEK_SET); src = (unsigned char*)opj_realloc(src, box.length); + if (src == NULL) { + opj_event_msg(cio->cinfo, EVT_ERROR, "Error reallocation memory\n"); + opj_free(src); + return 1; + } + fsresult = fread(src, box.length, 1, file); if (fsresult != 1) { opj_event_msg(cio->cinfo, EVT_ERROR, "End of file reached while trying to read MOOV box\n"); + opj_free(src); return 1; } cio = opj_cio_open((opj_common_ptr)movie->cinfo, src, box.length); if (mj2_read_moov(movie, &img, cio)) { + opj_free(src); return 1; } diff --git a/src/lib/openmj2/mj2_convert.c b/src/lib/openmj2/mj2_convert.c index 65aa3bc6..0d7816b8 100644 --- a/src/lib/openmj2/mj2_convert.c +++ b/src/lib/openmj2/mj2_convert.c @@ -62,6 +62,7 @@ unsigned int OPJ_CALLCONV yuv_num_frames(mj2_tk_t * tk, char *infile) fprintf(stderr, "YUV does not contains any frame of %d x %d size\n", tk->w, tk->h); + fclose(f); return 0; } fclose(f); |
