Message ID | 20170722175012.29555-1-foobaz86@gmail.com |
---|---|
State | New |
Headers | show |
Le quartidi 4 thermidor, an CCXXV, foo86 a écrit : > Fixes CID 1409915. > --- > libavcodec/dcaadpcm.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/libavcodec/dcaadpcm.c b/libavcodec/dcaadpcm.c > index 8742c7ccf6..e00f81f011 100644 > --- a/libavcodec/dcaadpcm.c > +++ b/libavcodec/dcaadpcm.c > @@ -215,6 +215,9 @@ av_cold int ff_dcaadpcm_init(DCAADPCMEncContext *s) > return -1; > > s->private_data = av_malloc(sizeof(premultiplied_coeffs) * DCA_ADPCM_VQCODEBOOK_SZ); > + if (!s->private_data) > + return -1; Proper return code please. Even if it is unused by the surrounding code, it will make maintenance easier. (There is another -1 just above, wrong too. It should be replaced by "av_assert1(s);", but that is not important since it cannot be reached.) Regards,
On 7/22/2017 2:50 PM, foo86 wrote: > Fixes CID 1409915. > --- > libavcodec/dcaadpcm.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/libavcodec/dcaadpcm.c b/libavcodec/dcaadpcm.c > index 8742c7ccf6..e00f81f011 100644 > --- a/libavcodec/dcaadpcm.c > +++ b/libavcodec/dcaadpcm.c > @@ -215,6 +215,9 @@ av_cold int ff_dcaadpcm_init(DCAADPCMEncContext *s) > return -1; > > s->private_data = av_malloc(sizeof(premultiplied_coeffs) * DCA_ADPCM_VQCODEBOOK_SZ); > + if (!s->private_data) > + return -1; AVERROR(ENOMEM) You could while at it change the call to ff_dcaadpcm_init() in dcaenc.c to actually look and propagate this value. > + > precalc(s->private_data); > return 0; > } >
On Sat, Jul 22, 2017 at 07:55:05PM +0200, Nicolas George wrote: > Le quartidi 4 thermidor, an CCXXV, foo86 a écrit : > > Fixes CID 1409915. > > --- > > libavcodec/dcaadpcm.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/libavcodec/dcaadpcm.c b/libavcodec/dcaadpcm.c > > index 8742c7ccf6..e00f81f011 100644 > > --- a/libavcodec/dcaadpcm.c > > +++ b/libavcodec/dcaadpcm.c > > @@ -215,6 +215,9 @@ av_cold int ff_dcaadpcm_init(DCAADPCMEncContext *s) > > return -1; > > > > s->private_data = av_malloc(sizeof(premultiplied_coeffs) * DCA_ADPCM_VQCODEBOOK_SZ); > > + if (!s->private_data) > > > + return -1; > > Proper return code please. Even if it is unused by the surrounding code, > it will make maintenance easier. Changed to AVERROR(ENOMEM) and pushed, thanks. > (There is another -1 just above, wrong too. It should be replaced by > "av_assert1(s);", but that is not important since it cannot be reached.)
On Sat, Jul 22, 2017 at 03:33:18PM -0300, James Almer wrote: > On 7/22/2017 2:50 PM, foo86 wrote: > > Fixes CID 1409915. > > --- > > libavcodec/dcaadpcm.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/libavcodec/dcaadpcm.c b/libavcodec/dcaadpcm.c > > index 8742c7ccf6..e00f81f011 100644 > > --- a/libavcodec/dcaadpcm.c > > +++ b/libavcodec/dcaadpcm.c > > @@ -215,6 +215,9 @@ av_cold int ff_dcaadpcm_init(DCAADPCMEncContext *s) > > return -1; > > > > s->private_data = av_malloc(sizeof(premultiplied_coeffs) * DCA_ADPCM_VQCODEBOOK_SZ); > > + if (!s->private_data) > > + return -1; > > AVERROR(ENOMEM) Changed. > You could while at it change the call to ff_dcaadpcm_init() in dcaenc.c > to actually look and propagate this value. I think this needs to be in a separate patch since it is not directly related to fixing Coverity issue.
diff --git a/libavcodec/dcaadpcm.c b/libavcodec/dcaadpcm.c index 8742c7ccf6..e00f81f011 100644 --- a/libavcodec/dcaadpcm.c +++ b/libavcodec/dcaadpcm.c @@ -215,6 +215,9 @@ av_cold int ff_dcaadpcm_init(DCAADPCMEncContext *s) return -1; s->private_data = av_malloc(sizeof(premultiplied_coeffs) * DCA_ADPCM_VQCODEBOOK_SZ); + if (!s->private_data) + return -1; + precalc(s->private_data); return 0; }