diff options
| author | mayeut <mayeut@users.noreply.github.com> | 2015-10-17 02:55:09 +0200 |
|---|---|---|
| committer | mayeut <mayeut@users.noreply.github.com> | 2015-10-17 02:55:09 +0200 |
| commit | 8034ffde8b108957aeff801c30b1a4c31e147e55 (patch) | |
| tree | 0de1362dce9993be1f4924dbcf81d3df275e67c7 /src/lib/openjp2/tcd.c | |
| parent | b3a15954f6bad45b8f2e8ae8f1d97fe40f5d5dc8 (diff) | |
Fix inconsistent behavior of malloc(0)
Update #635
Update #625
Diffstat (limited to 'src/lib/openjp2/tcd.c')
| -rw-r--r-- | src/lib/openjp2/tcd.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lib/openjp2/tcd.c b/src/lib/openjp2/tcd.c index 5e20a7a0..6eeb211e 100644 --- a/src/lib/openjp2/tcd.c +++ b/src/lib/openjp2/tcd.c @@ -871,7 +871,7 @@ static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no, l_band->stepsize = (OPJ_FLOAT32)(((1.0 + l_step_size->mant / 2048.0) * pow(2.0, (OPJ_INT32) (numbps - l_step_size->expn)))) * fraction; l_band->numbps = l_step_size->expn + (OPJ_INT32)l_tccp->numgbits - 1; /* WHY -1 ? */ - if (! l_band->precincts) { + if (!l_band->precincts && (l_nb_precincts > 0U)) { l_band->precincts = (opj_tcd_precinct_t *) opj_malloc( /*3 * */ l_nb_precinct_size); if (! l_band->precincts) { return OPJ_FALSE; @@ -930,7 +930,7 @@ static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no, /*fprintf(stderr, "\t\t\t\t precinct_cw = %d x recinct_ch = %d\n",l_current_precinct->cw, l_current_precinct->ch); */ l_nb_code_blocks_size = l_nb_code_blocks * (OPJ_UINT32)sizeof_block; - if (! l_current_precinct->cblks.blocks) { + if (!l_current_precinct->cblks.blocks && (l_nb_code_blocks > 0U)) { l_current_precinct->cblks.blocks = opj_malloc(l_nb_code_blocks_size); if (! l_current_precinct->cblks.blocks ) { return OPJ_FALSE; |
