From patchwork Tue Feb 13 07:51:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?R2FuZyBGYW4o6IyD5YiaKQ==?= X-Patchwork-Id: 7580 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.150.1 with SMTP id c1csp754275jai; Mon, 12 Feb 2018 23:52:41 -0800 (PST) X-Google-Smtp-Source: AH8x225PJNXAB3+cTtJyPWiqHSodCcCdD5zGXxUPfqBV54o+XgbbdT6lPhMEZd2tFvovSN06qBhd X-Received: by 10.28.231.22 with SMTP id e22mr430568wmh.109.1518508361264; Mon, 12 Feb 2018 23:52:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518508361; cv=none; d=google.com; s=arc-20160816; b=YzONfvtZgEkihBXlCQaD0gombUjlbiRMhU6gLR1QggmI5JbCSVsS4NcFbkOQUEhzna Y0q/RePWrEgmjpzV96DkEO8qDltkbyHugEFG3XXB+GulF0kzR9X16yT+BvpA58T2krnD n8LBLSUp2ttrXUt/7A3RpTXExfmXnmc7zOmrePy/twHw977B0lXl8XNw19zwmoN8GtSA IdzDEt8eFzgfWToU1GwJlspSlAozB5Zn4lbeBlyk7rrgxTwuv9nFmN15ZshPaGCGVMV0 9jn5S+czHll35z/tjGyVvuEZ8QposoJkwv6XcsGUc0M9VLh3Zupv24jn0/AZjfoz3c+S pxgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:to :message-id:date:from:references:in-reply-to:mime-version :dkim-signature:delivered-to:arc-authentication-results; bh=6vI/ooysaVqeSVLNCd/qeEB18wW9PQ5a2knPRoImC6o=; b=ETVxRhrPF6WlAxfam4GUtpd/kel6AGdfk4UY/0rXPiYGl7rX9mBQl8OE5JHNk2F43z DUDDY8fXrxeqJdwy80UCWRhsnanxkm77CwieI0EwAJaKyram7LXisxHVAtbq/5aGJYmz PlLTkOOMinS85RLTw0HN9mxae6BpRILFjltIKNgWugCljZb4T1DBwws0G+D2sfP+7XsW 4xEyQqiQSA4JUo+wtiKBwgkjkqMgl4TNrCBNmd6hshSHIDhWZB/OSlfzTpILv2QT2ecx FDQfvBFN64GVDGoxnMNGjdzhzp3V1E6HjPbWLgc33bq0vIhBCypA5/MXXU2S4U/fEQcX 5iHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=kiNUHIn/; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id i18si4998972wmd.57.2018.02.12.23.52.38; Mon, 12 Feb 2018 23:52:41 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=kiNUHIn/; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 744C1689BE3; Tue, 13 Feb 2018 09:52:26 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-yw0-f169.google.com (mail-yw0-f169.google.com [209.85.161.169]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6218E689828 for ; Tue, 13 Feb 2018 09:52:20 +0200 (EET) Received: by mail-yw0-f169.google.com with SMTP id e65so3179934ywh.9 for ; Mon, 12 Feb 2018 23:52:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=1IY+uosQaIO0nChwE9rScHP8gGv28kq9u9ojI7Rod7E=; b=kiNUHIn/DHm9qS7Sdz6RG06/VmLwKerODPfb2sl4mAIsf97hvOCya64qd/qcK7I/DW h8r9mFqnIOJALqFvJ1l4SgVn+PMFC0lEZW3lg4d+XINLJq1JUavvk7U3vnTRJVTGgUog uUvhD243t6/7Rn+9TwZNynayvjUZULIFWfHlLwbCincVz+er61KekI/UJRHk+vecFzck reHRGoYir81pZBna9veAmCCq9A0ST1aqHorOUy+TcqD8Y9UX1rOxuxZZyxy5sY3B9lSC oCKrwaTbh+yY8Vm1H91Np0C9WdYshZEhtJMWX4SON5FRceL00qI7Z4epbt73gNrvp23u vnrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=1IY+uosQaIO0nChwE9rScHP8gGv28kq9u9ojI7Rod7E=; b=e+lRltRYwocSgNzoSHQjZFEUU5kQhru7BpQSh46hR3KVztRaV2DPsMhWYA00ciHPOX lytFeWpV4eJ5GH07zGS09V1A0z4LxnAAwqAaiypITqJGHB4AFk25tC3I6mfSuka4aazT ENJinsvDHxPhOfU4i5E0aJRzz7vJHQv0QzczLZX5llggPTBj9ShMRPF6HRpEkRFYwzVt HeSlMkKWptJ1iWJBm3kAZwdn9UDxmL1kLtqPrJbHs0g4X3vr6bqkqX1/KndFHfE0fPug gWR1AQocqB9SrhDF7+2jl1/Q1VmV8yRNUcQ0cHsfe2fu8LUhlQ+JkespqE1qemz6eLZd 2/7A== X-Gm-Message-State: APf1xPAsg4/Ni1uX2UxTlMNPglrCLB8tu4R6lHu0ksli6c5I65jq5Exs XkCAzk6755GCG9hyJ9ZqOhJrr0iAT9IO6EsqiMwceg== X-Received: by 10.129.199.71 with SMTP id i7mr158266ywl.332.1518508349482; Mon, 12 Feb 2018 23:52:29 -0800 (PST) MIME-Version: 1.0 Received: by 10.37.215.214 with HTTP; Mon, 12 Feb 2018 23:51:48 -0800 (PST) In-Reply-To: References: <20180212215928.264ef239@debian> From: =?UTF-8?B?R2FuZyBGYW4o6IyD5YiaKQ==?= Date: Tue, 13 Feb 2018 15:51:48 +0800 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: Re: [FFmpeg-devel] [PATCH] avcodec/ass: Fix a memory leak defect. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Here is the patch. On Tue, Feb 13, 2018 at 3:30 PM, Gang Fan(范刚) wrote: > Thanks for the advice, let me have another try. > > On Tue, Feb 13, 2018 at 4:59 AM, wm4 wrote: > >> On Mon, 12 Feb 2018 20:56:25 +0800 >> Gang Fan(范刚) wrote: >> >> > Thanks to Hendrik >> > Here is the new patch: >> > >> > From 642a413080f20f9515321e42056248e86e003997 Mon Sep 17 00:00:00 2001 >> > From: Fan Gang >> > Date: Mon, 12 Feb 2018 20:55:06 +0800 >> > Subject: [PATCH] avcodec/ass: Fix a memory leak defect when realloc >> fails. >> > >> > --- >> > libavcodec/ass_split.c | 6 ++---- >> > 1 file changed, 2 insertions(+), 4 deletions(-) >> > >> > diff --git a/libavcodec/ass_split.c b/libavcodec/ass_split.c >> > index 872528b..eebe239 100644 >> > --- a/libavcodec/ass_split.c >> > +++ b/libavcodec/ass_split.c >> > @@ -249,7 +249,7 @@ static const char *ass_split_section(ASSSplitCon >> text >> > *ctx, const char *buf) >> > const ASSSection *section = &ass_sections[ctx->current_section]; >> > int *number = &ctx->field_number[ctx->current_section]; >> > int *order = ctx->field_order[ctx->current_section]; >> > - int *tmp, i, len; >> > + int i, len; >> > >> > while (buf && *buf) { >> > if (buf[0] == '[') { >> > @@ -280,9 +280,7 @@ static const char *ass_split_section(ASSSplitCon >> text >> > *ctx, const char *buf) >> > while (!is_eol(*buf)) { >> > buf = skip_space(buf); >> > len = strcspn(buf, ", \r\n"); >> > - if (!(tmp = av_realloc_array(order, (*number + 1), >> > sizeof(*order)))) >> > - return NULL; >> > - order = tmp; >> > + av_reallocp_array(&order, (*number + 1), >> > sizeof(*order)); >> > order[*number] = -1; >> > for (i=0; section->fields[i].name; i++) >> > if (!strncmp(buf, section->fields[i].name, >> len)) { >> >> The patch formatting is broken (line breaks). It will be cumbersome to >> apply it, which most likely will mean nobody is going to try. >> >> Never copy&paste a patch into the text field of your email client. >> Instead you should do one of these things: >> >> - just attach the patch as text attachment >> - use git send-email >> _______________________________________________ >> ffmpeg-devel mailing list >> ffmpeg-devel@ffmpeg.org >> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> > > > > -- > > > *With kind regards* > From 5c66208ebdf94a854fdae823e58b164f2f8056b1 Mon Sep 17 00:00:00 2001 From: Fan Gang Date: Tue, 13 Feb 2018 15:38:59 +0800 Subject: [PATCH] avcodec/ass: Fix a memory leak defect when realloc fails. --- libavcodec/ass_split.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/ass_split.c b/libavcodec/ass_split.c index 872528b..67da7c6 100644 --- a/libavcodec/ass_split.c +++ b/libavcodec/ass_split.c @@ -249,7 +249,7 @@ static const char *ass_split_section(ASSSplitContext *ctx, const char *buf) const ASSSection *section = &ass_sections[ctx->current_section]; int *number = &ctx->field_number[ctx->current_section]; int *order = ctx->field_order[ctx->current_section]; - int *tmp, i, len; + int i, len; while (buf && *buf) { if (buf[0] == '[') { @@ -280,9 +280,9 @@ static const char *ass_split_section(ASSSplitContext *ctx, const char *buf) while (!is_eol(*buf)) { buf = skip_space(buf); len = strcspn(buf, ", \r\n"); - if (!(tmp = av_realloc_array(order, (*number + 1), sizeof(*order)))) + if (av_reallocp_array(&order, (*number + 1), sizeof(*order)) != 0) return NULL; - order = tmp; + order[*number] = -1; for (i=0; section->fields[i].name; i++) if (!strncmp(buf, section->fields[i].name, len)) { -- 1.9.1