diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-10-15 19:51:49 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-10-15 19:51:49 +0200 |
commit | 0de5693026e9e2bd2799f3e1e4e7d929a14271b7 (patch) | |
tree | c5ae0d6191421582a194232b6a85d791a6518cc5 | |
parent | f71355829ab07f9632e3c1195f8bffa50e40826e (diff) | |
download | libextractor-0de5693026e9e2bd2799f3e1e4e7d929a14271b7.tar.gz libextractor-0de5693026e9e2bd2799f3e1e4e7d929a14271b7.zip |
fix duration initialization in ffmpeg extractor (badly positioned #if)
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | src/plugins/thumbnailffmpeg_extractor.c | 28 |
2 files changed, 14 insertions, 17 deletions
@@ -2,7 +2,8 @@ Sun Oct 15 19:36:41 CEST 2017 | |||
2 | Fix potential file descriptor leak (on error handling path). | 2 | Fix potential file descriptor leak (on error handling path). |
3 | Fix potential assign-after-free (on IPC error handling path). | 3 | Fix potential assign-after-free (on IPC error handling path). |
4 | Make sure to only pass "unsigned char" to functions like isspace(). | 4 | Make sure to only pass "unsigned char" to functions like isspace(). |
5 | Avoid malloc(0) in DEB extractor under certain conditions. -CG | 5 | Avoid malloc(0) in DEB extractor under certain conditions. |
6 | Properly initialize 'duration' in ffmpeg extractor. -CG | ||
6 | 7 | ||
7 | Fri Oct 13 12:30:37 CEST 2017 | 8 | Fri Oct 13 12:30:37 CEST 2017 |
8 | Properly check read error in NSF plugin (from signedness confusion) found by Leon Zhao. -CG | 9 | Properly check read error in NSF plugin (from signedness confusion) found by Leon Zhao. -CG |
diff --git a/src/plugins/thumbnailffmpeg_extractor.c b/src/plugins/thumbnailffmpeg_extractor.c index 0619efd..c2af240 100644 --- a/src/plugins/thumbnailffmpeg_extractor.c +++ b/src/plugins/thumbnailffmpeg_extractor.c | |||
@@ -621,6 +621,7 @@ extract_video (struct EXTRACTOR_ExtractContext *ec) | |||
621 | int err; | 621 | int err; |
622 | int frame_finished; | 622 | int frame_finished; |
623 | unsigned char *iob; | 623 | unsigned char *iob; |
624 | int duration; | ||
624 | 625 | ||
625 | if (NULL == (iob = av_malloc (16 * 1024))) | 626 | if (NULL == (iob = av_malloc (16 * 1024))) |
626 | return; | 627 | return; |
@@ -704,32 +705,27 @@ extract_video (struct EXTRACTOR_ExtractContext *ec) | |||
704 | av_free (io_ctx); | 705 | av_free (io_ctx); |
705 | return; | 706 | return; |
706 | } | 707 | } |
707 | int duration; | 708 | |
708 | if (format_ctx->duration == AV_NOPTS_VALUE) | 709 | if (format_ctx->duration == AV_NOPTS_VALUE) |
709 | { | 710 | { |
710 | duration = -1; | 711 | duration = -1; |
711 | #if DEBUG | 712 | #if DEBUG |
712 | fprintf (stderr, | 713 | fprintf (stderr, |
713 | "Duration unknown\n"); | 714 | "Duration unknown\n"); |
714 | #endif | 715 | #endif |
715 | } | 716 | } |
716 | else | 717 | else |
717 | { | 718 | { |
718 | #if DEBUG | 719 | duration = format_ctx->duration; |
719 | duration = format_ctx->duration; | 720 | } |
720 | fprintf (stderr, | ||
721 | "Duration: %lld\n", | ||
722 | format_ctx->duration); | ||
723 | #endif | ||
724 | } | ||
725 | 721 | ||
726 | /* if duration is known, seek to first tried, | 722 | /* if duration is known, seek to first tried, |
727 | * else use 10 sec into stream */ | 723 | * else use 10 sec into stream */ |
728 | 724 | ||
729 | if(-1 != duration) | 725 | if(-1 != duration) |
730 | err = av_seek_frame (format_ctx, -1, (duration/3), 0); | 726 | err = av_seek_frame (format_ctx, -1, (duration/3), 0); |
731 | else | 727 | else |
732 | err = av_seek_frame (format_ctx, -1, 10 * AV_TIME_BASE, 0); | 728 | err = av_seek_frame (format_ctx, -1, 10 * AV_TIME_BASE, 0); |
733 | 729 | ||
734 | if (err >= 0) | 730 | if (err >= 0) |
735 | avcodec_flush_buffers (codec_ctx); | 731 | avcodec_flush_buffers (codec_ctx); |