On 02/23/2012 05:22 AM, Anton Khirnov wrote:
>
> On Wed, 22 Feb 2012 19:57:14 -0500, Justin Ruggles <[email protected]>
> wrote:
>> ---
>> libavcodec/libfaac.c | 49
>> ++++++++++++++++++++++++++++++++-----------------
>> 1 files changed, 32 insertions(+), 17 deletions(-)
>>
>> diff --git a/libavcodec/libfaac.c b/libavcodec/libfaac.c
>> index 997aa83..7e65d9b 100644
>> --- a/libavcodec/libfaac.c
>> +++ b/libavcodec/libfaac.c
>> @@ -31,16 +31,30 @@ typedef struct FaacAudioContext {
>> faacEncHandle faac_handle;
>> } FaacAudioContext;
>>
>> +
>> +static av_cold int Faac_encode_close(AVCodecContext *avctx)
>> +{
>> + FaacAudioContext *s = avctx->priv_data;
>> +
>> + av_freep(&avctx->coded_frame);
>> + av_freep(&avctx->extradata);
>> +
>> + faacEncClose(s->faac_handle);
>> + return 0;
>> +}
>> +
>> static av_cold int Faac_encode_init(AVCodecContext *avctx)
>> {
>> FaacAudioContext *s = avctx->priv_data;
>> faacEncConfigurationPtr faac_cfg;
>> unsigned long samples_input, max_bytes_output;
>> + int ret;
>>
>> /* number of channels */
>> if (avctx->channels < 1 || avctx->channels > 6) {
>> av_log(avctx, AV_LOG_ERROR, "encoding %d channel(s) is not
>> allowed\n", avctx->channels);
>> - return -1;
>> + ret = AVERROR(EINVAL);
>> + goto error;
>
> This will call faacEncClose on NULL if I'm reading it right. Is that
> allowed?
Maybe not. I'll try it out. If it's not allowed, I'll add a NULL check
in Faac_encode_close() before calling faacEncClose().
>> }
>>
>> s->faac_handle = faacEncOpen(avctx->sample_rate,
>> @@ -51,8 +65,8 @@ static av_cold int Faac_encode_init(AVCodecContext *avctx)
>> faac_cfg = faacEncGetCurrentConfiguration(s->faac_handle);
>> if (faac_cfg->version != FAAC_CFG_VERSION) {
>> av_log(avctx, AV_LOG_ERROR, "wrong libfaac version (compiled for:
>> %d, using %d)\n", FAAC_CFG_VERSION, faac_cfg->version);
>> - faacEncClose(s->faac_handle);
>> - return -1;
>> + ret = -1;
>> + goto error;
>
> Wouldn't EINVAL be better here. I know, it's not exactly correct here,
> but still better than permission denied.
yeah, I suppose EINVAL is at least a better choice.
Thanks,
Justin
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel