From patchwork Mon Feb 12 12:56:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?R2FuZyBGYW4o6IyD5YiaKQ==?= X-Patchwork-Id: 7572 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.150.1 with SMTP id c1csp3955524jai; Mon, 12 Feb 2018 04:57:16 -0800 (PST) X-Google-Smtp-Source: AH8x227BJ5yx2x7gxVxM+QDtjE0yfEBYQC8KLyUWkOc/9mDobWq0v+gEQOhbv2MgArvxWY7BUOKB X-Received: by 10.28.69.65 with SMTP id s62mr3607933wma.78.1518440236502; Mon, 12 Feb 2018 04:57:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518440236; cv=none; d=google.com; s=arc-20160816; b=wKGjLn6qGaTrDO+FhxBPtzuJMLppwl/fnXZRpY+hez/5OrNLydmtMg3Yi0d6Gdj0lM aVS5ZeoKQFY9IBt5Tvcg0sEn1ltpKgX22tmYqicbvAgQZ9N1A7FnP7aWPHKDO/VofKZ2 Pr1m25jWf1gYi9T0GrSaFWtlusEi5F0Ocv+GGf75V62Kf/L7pawghBBQc/hOkS/VQKtB 7hn685wVlpSjiTa9lMfkrMV6iUotBPnt8707p3ClRPELPBY7NZ/oMzfhfhW3qEvTogWU ePSzae8GwouA3KpXCZObebBbdOlTyasVwkBBdzgFv2ArCI0XJ+OJUcJ4+BC5ZvuCZ+DS vSfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=ZHasU1CaMmhg8y3oOTgazHl5rDvQ8eJ8RbDljD/eAc4=; b=e4IwPAHkAQO398YRXdpA3qS8jgadS2RYXSa7+xZVnO8cfHo4y/GaBCXkdq/ME+4NU/ ub8UYnQtG3I4YjxcyiZH5K6vBXSiJ+xtSZ4+04JUdgVs/f1kRtDGN0RXIxj01P4+z2iQ Pf3zFUc6vs344PgY8lf1xu3xLut9adnMXIEKP5rEXAEp1UqZJJdbyQEmuXAI240SSuca 4JMGVU3uoUw3drEge+FpTfOFBAxZj8u//oqMLvNIM9eUid+9tw5TyoU5+LdtYIk7gLyD HB1GQ80z3xApwttbEMV7eQRjncV0hDZRXqp5VdMh97V1UseJ3N3WJNx8IkBuimWXEVGx iKhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=T3xJmjyu; 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 s5si312767wrg.348.2018.02.12.04.57.15; Mon, 12 Feb 2018 04:57:16 -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=T3xJmjyu; 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 92C8B689A7B; Mon, 12 Feb 2018 14:57:03 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-yw0-f174.google.com (mail-yw0-f174.google.com [209.85.161.174]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 863C968922A for ; Mon, 12 Feb 2018 14:56:56 +0200 (EET) Received: by mail-yw0-f174.google.com with SMTP id m84so9777612ywd.5 for ; Mon, 12 Feb 2018 04:57:07 -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=cstpqgN7tzBQJeNjArUdTJwWPYGuRKT667VQL0YnO2k=; b=T3xJmjyui5mQ7+fOMYeIeLvGxg3pjH1ht9kVV/QkhIQdmE7LSwNuu0oWANXprfgOjv GBLavyZ9dFoFZwlUSUhuj53r9Ul1I2Yt49ATStzXQ4QZkq0JbGp05RXm5dp+wOWUgrTL LzOmE9TC2HGIH32Qm1AoDP/UY4ZwBKUtIrFaiK/khaMdLeeqA6/7yBWMFDBqCAiqTqcW c4dksozq9a/MzCYr/s15f3K/QcK3zlMvBOXEPsOAiwDcRwrR7COjpX+MEO3bt6VIip8d fCliED+y4Rlg1xMNuQUACYCSSqHgmis0W6EFavwbThCEsm7pkaoFuPQbtzjr0lhVve3R NIuQ== 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=cstpqgN7tzBQJeNjArUdTJwWPYGuRKT667VQL0YnO2k=; b=MB1cHrGdygrhxqXuej33rXWig+QNI5cg3AhFz1smChoZ/JpvLoj3SDPtp+/nE0VoTK 7pU4xm3lw35uMnf/ZoaAxqIhXeC/LUvkpb5WaNoTnvwWErI7pTy66tvcqPp+PvE5S0jE 0HzpMFARV/VjFScIAmYJVGInIOhin3VAnY1EJ/GQEgW+BdmE9Mj4nmJJesTGz7cDs/EG l71YXs2LYArVrJ3EYFnExgNPInJ+sVdmRvWbjvrl9ML1QVeFNxAZWs/seLsptgs0N8T5 dPn+16wClp99njuzZO7vtel3XEJbJQj5V7gXn4zkv1RFCVtbndk6yUiTppUBYvAW02ay BdIg== X-Gm-Message-State: APf1xPD6Okp6tJKJjR7C2swenif+9QRfxIj28co4YqtOrIeJRvNJHEFS rsxJtWy3Y2I86hXKXRCGZ8422tTX7dL451FTXLz+7paZ X-Received: by 10.129.164.204 with SMTP id b195mr727181ywh.451.1518440225632; Mon, 12 Feb 2018 04:57:05 -0800 (PST) MIME-Version: 1.0 Received: by 10.37.215.214 with HTTP; Mon, 12 Feb 2018 04:56:25 -0800 (PST) In-Reply-To: References: From: =?UTF-8?B?R2FuZyBGYW4o6IyD5YiaKQ==?= Date: Mon, 12 Feb 2018 20:56:25 +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" 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(-) if (buf[0] == '[') { @@ -280,9 +280,7 @@ 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)))) - 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)) { 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(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) {