diff options
| author | Mathieu Malaterre <mathieu.malaterre@gmail.com> | 2014-03-03 11:36:31 +0000 |
|---|---|---|
| committer | Mathieu Malaterre <mathieu.malaterre@gmail.com> | 2014-03-03 11:36:31 +0000 |
| commit | 25255c4ed1cb1974857189a2a5c67f878c923cc3 (patch) | |
| tree | c174ee9190f9a9885ecf917c5c86639871d9c902 /src/lib/openjpip/jpipstream_manager.c | |
| parent | 16febebd28aafe8a47472d669b399dded8f84c5e (diff) | |
[trunk] remove all api with invalid FILE* parameters which could leads to issues when applications are compiled with different flags from openjpeg.
Fixes issue 198
Diffstat (limited to 'src/lib/openjpip/jpipstream_manager.c')
| -rw-r--r-- | src/lib/openjpip/jpipstream_manager.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/lib/openjpip/jpipstream_manager.c b/src/lib/openjpip/jpipstream_manager.c index 3227af75..6649129c 100644 --- a/src/lib/openjpip/jpipstream_manager.c +++ b/src/lib/openjpip/jpipstream_manager.c @@ -76,19 +76,34 @@ Byte_t * jpipstream_to_pnm( Byte_t *jpipstream, msgqueue_param_t *msgqueue, Byte Byte_t *pnmstream; Byte_t *j2kstream; /* j2k or jp2 codestream */ Byte8_t j2klen; + size_t retlen; FILE *fp; const char j2kfname[] = "tmp.j2k"; + fp = fopen( j2kfname, "w+b"); + if( !fp ) + { + return NULL; + } j2kstream = recons_j2k( msgqueue, jpipstream, csn, fw, fh, &j2klen); + if( !j2kstream ) + { + fclose(fp); + remove( j2kfname); + return NULL; + } - fp = fopen( j2kfname, "w+b"); - fwrite( j2kstream, j2klen, 1, fp); + retlen = fwrite( j2kstream, 1, j2klen, fp); opj_free( j2kstream); - fseek( fp, 0, SEEK_SET); + fclose(fp); + if( retlen != j2klen ) + { + remove( j2kfname); + return NULL; + } - pnmstream = j2k_to_pnm( fp, ihdrbox); + pnmstream = j2k_to_pnm( j2kfname, ihdrbox); - fclose( fp); remove( j2kfname); return pnmstream; |
