On 12/8/15 7:05 PM, Hendrik Leppkes wrote:
On Tue, Dec 8, 2015 at 11:46 AM, Lvqier <lvq...@gmail.com> wrote:
On 12/8/15 6:26 PM, Hendrik Leppkes wrote:
On Tue, Dec 8, 2015 at 11:19 AM, Lvqier <lvq...@gmail.com> wrote:
Hi Hendrik,

      The attached is another patch which uses av_reallocp to fix this
issue.

Thanks, that looks almost good. But you should check for a negative
return value, as all errors are negative.
Do you mean that the set_segment_filename function should return the value
which returns from av_reallocp instead of AVERROR(ENOMEM) when it fails?
That would be an option too, but right now you just do
if(av_reallop(..)), at the least this should be if (av_reallocp(...) <
0)

or even better:
ret = av_reallocp(...);
if (ret < 0)
     return ret;
Thank you, I will follow your advice. Please help review this version. I have studied some code where av_reallocp is used before sending it out.

- Hendrik
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

--
/Best Regards,
lvqier - lvq...@gmail.com <mailto:lvq...@gmail.com>
/

******************************************
青春如烟,唱一首笑忘歌

diff --git a/libavformat/segment.c b/libavformat/segment.c
index 8432d0f..0c1f633 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -183,6 +183,7 @@ static int set_segment_filename(AVFormatContext *s)
     SegmentContext *seg = s->priv_data;
     AVFormatContext *oc = seg->avf;
     size_t size;
+    int ret;
 
     if (seg->segment_idx_wrap)
         seg->segment_idx %= seg->segment_idx_wrap;
@@ -206,9 +207,8 @@ static int set_segment_filename(AVFormatContext *s)
     if (seg->entry_prefix)
         size += strlen(seg->entry_prefix);
 
-    seg->cur_entry.filename = av_mallocz(size);
-    if (!seg->cur_entry.filename)
-        return AVERROR(ENOMEM);
+    if ((ret = av_reallocp(&seg->cur_entry.filename, size)) < 0)
+        return ret;
     snprintf(seg->cur_entry.filename, size, "%s%s",
              seg->entry_prefix ? seg->entry_prefix : "",
              av_basename(oc->filename));
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to