diff mbox

[FFmpeg-devel] ffmpeg: fix uninitialized return value

Message ID 1479802586-26759-1-git-send-email-t.rapp@noa-archive.com
State Superseded
Headers show

Commit Message

Tobias Rapp Nov. 22, 2016, 8:16 a.m. UTC
Signed-off-by: Tobias Rapp <t.rapp@noa-archive.com>
---
 ffmpeg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Michael Niedermayer Nov. 22, 2016, 1:34 p.m. UTC | #1
On Tue, Nov 22, 2016 at 09:16:26AM +0100, Tobias Rapp wrote:
> Signed-off-by: Tobias Rapp <t.rapp@noa-archive.com>
> ---
>  ffmpeg.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

do you have a testcase for this ?

[...]
Tobias Rapp Nov. 22, 2016, 1:43 p.m. UTC | #2
On 22.11.2016 14:34, Michael Niedermayer wrote:
> On Tue, Nov 22, 2016 at 09:16:26AM +0100, Tobias Rapp wrote:
>> Signed-off-by: Tobias Rapp <t.rapp@noa-archive.com>
>> ---
>>  ffmpeg.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> do you have a testcase for this ?

No, I just stumbled over it when reading the code.

Regards,
Tobias
Michael Niedermayer Nov. 22, 2016, 2:06 p.m. UTC | #3
On Tue, Nov 22, 2016 at 02:43:57PM +0100, Tobias Rapp wrote:
> On 22.11.2016 14:34, Michael Niedermayer wrote:
> >On Tue, Nov 22, 2016 at 09:16:26AM +0100, Tobias Rapp wrote:
> >>Signed-off-by: Tobias Rapp <t.rapp@noa-archive.com>
> >>---
> >> ffmpeg.c | 2 +-
> >> 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> >do you have a testcase for this ?
> 
> No, I just stumbled over it when reading the code.

are you sure that the codepath leaving ret uninitialized is possible ?

if not adding a av_assert() may be better

[...]
Tobias Rapp Nov. 22, 2016, 2:34 p.m. UTC | #4
On 22.11.2016 15:06, Michael Niedermayer wrote:
> On Tue, Nov 22, 2016 at 02:43:57PM +0100, Tobias Rapp wrote:
>> On 22.11.2016 14:34, Michael Niedermayer wrote:
>>> On Tue, Nov 22, 2016 at 09:16:26AM +0100, Tobias Rapp wrote:
>>>> Signed-off-by: Tobias Rapp <t.rapp@noa-archive.com>
>>>> ---
>>>> ffmpeg.c | 2 +-
>>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> do you have a testcase for this ?
>>
>> No, I just stumbled over it when reading the code.
>
> are you sure that the codepath leaving ret uninitialized is possible ?
>
> if not adding a av_assert() may be better

 From my quick glance I assumed that ist->nb_filters could be zero and 
the for-loop is not entered. If that should never be the case I agree 
that an added av_assert(ist->nb_filters > 0) would be better.

Regards,
Tobias
diff mbox

Patch

diff --git a/ffmpeg.c b/ffmpeg.c
index c47a824..4e58528 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -2067,7 +2067,7 @@  static int decode(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacke
 
 static int send_frame_to_filters(InputStream *ist, AVFrame *decoded_frame)
 {
-    int i, ret;
+    int i, ret = 0;
     AVFrame *f;
 
     for (i = 0; i < ist->nb_filters; i++) {