On Sat, 14 Jun 2014 21:56:53 +0530, Nidhi Makhijani <[email protected]> wrote: > --- > libavformat/hevc.c | 17 ++++++++++++++--- > 1 file changed, 14 insertions(+), 3 deletions(-) > > diff --git a/libavformat/hevc.c b/libavformat/hevc.c > index 37b35b4..72a8d04 100644 > --- a/libavformat/hevc.c > +++ b/libavformat/hevc.c > @@ -693,7 +693,7 @@ static int hvcc_array_add_nal_unit(uint8_t *nal_buf, > uint32_t nal_size, > > ret = av_reallocp_array(&hvcc->array, index + 1, > sizeof(HVCCNALUnitArray)); > if (ret < 0) > - return ret; > + goto fail; > > for (i = hvcc->numOfArrays; i <= index; i++) > memset(&hvcc->array[i], 0, sizeof(HVCCNALUnitArray)); > @@ -705,11 +705,12 @@ static int hvcc_array_add_nal_unit(uint8_t *nal_buf, > uint32_t nal_size, > > ret = av_reallocp_array(&array->nalUnit, numNalus + 1, sizeof(uint8_t*)); > if (ret < 0) > - return ret; > + goto fail; > > ret = av_reallocp_array(&array->nalUnitLength, numNalus + 1, > sizeof(uint16_t)); > if (ret < 0) > - return ret; > + goto fail; > + > > array->nalUnit [numNalus] = nal_buf; > array->nalUnitLength[numNalus] = nal_size; > @@ -726,6 +727,16 @@ static int hvcc_array_add_nal_unit(uint8_t *nal_buf, > uint32_t nal_size, > array->array_completeness = ps_array_completeness; > > return 0; > + > +fail: > + for (index = 0; index < hvcc->numOfArrays; index++) { > + hvcc->array[index].numNalus = 0; > + av_freep(&hvcc->array[index].nalUnit); > + av_freep(&hvcc->array[index].nalUnitLength); > + } > + hvcc->numOfArrays = 0; > + av_freep(&hvcc->array); > + return ret;
This is unnecessary and wrong, since hvcc is not owned or allocated by this function and thus should not be freed by it. The caller will already properly free it on error. -- Anton Khirnov _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
