From patchwork Fri Aug 25 18:25:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Rummell X-Patchwork-Id: 4840 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.15.201 with SMTP id 70csp557690jao; Fri, 25 Aug 2017 11:32:30 -0700 (PDT) X-Received: by 10.28.29.75 with SMTP id d72mr175318wmd.152.1503685950819; Fri, 25 Aug 2017 11:32:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503685950; cv=none; d=google.com; s=arc-20160816; b=pZg8uMK7FFsA5OjTYCsjrIu6h6KmQy7xoNSYIsSDENTeYtSi0FY0zkPPYKlp/tWVxi w1WT8A+Vz6zCyZ0j3GfbGgyIkc0BhTNnIO91QJ/4w9eoocxEkxKXLIFk/G2BJZ8zS8RR Fq4qna3V7Nn9FhYD9/YVifh193623e857y3PA5aZTxIznTpQnm5KXBex8+3Kex1GgfRq 8GbP27RzImCoXPsJ9qxNRM3uCdWG2bzjCjYg6gRT5CcKLazOaEYZlFiB2dQSU7T6+jmn C3GE2HI8sH4I/1KREg9bqzUsp0ulD0TXktMz3DSD8nOn00xyjPA29tJu3gTLjESssVT5 caRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:to :message-id:date:from:mime-version:dkim-signature:dkim-signature :delivered-to:arc-authentication-results; bh=lK6vn+mCXquov4MBO/qsWPngEYgKpo4ZEUtuAForCHE=; b=URYRVcHDLVnFGsS0C90BCaS8OSbCI3wYQoj1pM7ngHFL/7i1wg+1HJ6jYHcJd3/AwA R+W1dhG/hDYS1bzH5oI1mnjLPRQD80xPKUs5/vLjb5rgANJzrq3QIYjGl4jDIUno5N1J tMcJtcJ6+/AgBmQ8dUl2pMBx9iSpoN8wicsr/SF86gQNKZCx+VFpE2NgYLzQWgMw0VkA qX0D217PCGaJtipWV4qN1u7cxXgn00BPN4+3p+B3aTq+ieMTNpLz7EepG/y8F9lBo8nP 3OvVRzZ1YvbkxThNrOHli6/p3eP3INQ/pQfYV379uvHPF9g9B93JrxBjevCdiZOEdt6G thNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@google.com header.s=20161025 header.b=RAVci8In; dkim=neutral (body hash did not verify) header.i=@chromium.org header.s=google header.b=lGIUBnc0; 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=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id r16si5977212wrc.192.2017.08.25.11.32.29; Fri, 25 Aug 2017 11:32:30 -0700 (PDT) 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=@google.com header.s=20161025 header.b=RAVci8In; dkim=neutral (body hash did not verify) header.i=@chromium.org header.s=google header.b=lGIUBnc0; 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=NONE dis=NONE) header.from=chromium.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0F686689A8B; Fri, 25 Aug 2017 21:32:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ua0-f181.google.com (mail-ua0-f181.google.com [209.85.217.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B4B4B689A2D for ; Fri, 25 Aug 2017 21:32:11 +0300 (EEST) Received: by mail-ua0-f181.google.com with SMTP id d12so2117255uag.0 for ; Fri, 25 Aug 2017 11:32:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:sender:from:date:message-id:subject:to:cc; bh=eWr5fGAp2Cmo1vYthql4sGD6RqUuMbpWBV7txYvHv2E=; b=RAVci8InkWRXspSRTgPMspN8BybLTB69Rf80kpGGiQ+S3Qv1SBibbkyrvNZEX2mgJg j4s0Db3uI0TCr5SMVVRb4F41j+PHgVAV/bpwCloKCxwQcd7+K5qSzrdNdZdSxPghuSW1 Vg/vWXAUCXqCH0LbN8f4T4tdeHOVTF1OybhaCC/cqtOWlehFtJvMhtBsetpBorRc0Dz1 EkgX1juwxzc3yjLDPvdd2cKEqV/UpbzzlaqGlthd5jeBlHRhQdLmmfOs9GXBHPfOZfwv xcQkMfGi7rAyVEfeFNfD7nUhgcumVxRaCnL+kO2ltfZJG8Dyq7YgaGZXMVCf1pGI/GTW T58g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:sender:from:date:message-id:subject:to:cc; bh=eWr5fGAp2Cmo1vYthql4sGD6RqUuMbpWBV7txYvHv2E=; b=lGIUBnc02GPQb/prgs52UVFAMeomHAstuezLxnUDEXbead/v+z9rOvpxxD00vrdYrE iu+OMM2qkCM4O95qcNo1KpFHNI8pq2U2bUSyAJPkAeIR3EgzEGzjbXinh7gjEU7bj5+Y Q2rAQbbPPaIwWlwb2r7dPkJw3KPElkQuV2z6c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:from:date:message-id:subject :to:cc; bh=eWr5fGAp2Cmo1vYthql4sGD6RqUuMbpWBV7txYvHv2E=; b=qHbsDfUiLnguwz3/5uP41bpfEctB7OZVkU7Pp6o6D9sYQzhcTJGn3kHfrJIxCPM3eD oG2iy446reAZYdzpeoQ9mvQ5QFhIlQFPxTU539BdQ6GFFOmjcJq3MI48NfwxgcYdFIlD cs5rHeskPhzbj0LztoJBW/ljZ97aUNgXy1yX2GgTXa9maz/d+BYsYROoE37Q6tw0a6P0 uaobszd774UobpP6uNUFy+9xX3GaPDiWQCKsMOEHzR8n3ZRWMXXuZi6gyolJSaoMs1D+ YIIdBOoZAOnBYognaXwVPZuF9+tctzdliDS8gk5DkZIvhS8qUZK+tmBYK97Zm3VPOmNA LX/Q== X-Gm-Message-State: AHYfb5gOBNs6fnBYnZUBsmUcjhuBDrk5ucqBOIN3yBZlbiTrdNHQpEKR w37ARAfJ15sJQHUNcSE1OyXdC8BcmN+brlbs/w== X-Google-Smtp-Source: ADKCNb7JXJ0cPzwy1GwrbF1Nqnz9K6xW/07lbI68W+e1H5p8CYpYqHrZXSUhEKUapmjhvZ859tjpe32ZmjoyUfDIqLQ= X-Received: by 10.176.75.103 with SMTP id i39mr6089114uaf.129.1503685512341; Fri, 25 Aug 2017 11:25:12 -0700 (PDT) MIME-Version: 1.0 Received: by 10.31.164.71 with HTTP; Fri, 25 Aug 2017 11:25:11 -0700 (PDT) From: John Rummell Date: Fri, 25 Aug 2017 11:25:11 -0700 X-Google-Sender-Auth: cDJCo4MeoX-hXt-PKpQdy0az8JY Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: [FFmpeg-devel] [PATCH] libavformat/mov: Always use av_realloc() for AVCodecParameters.extradata 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 Cc: Dale Curtis Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Chromium uses tcmalloc which doesn't like mixing calls to posix_memalign() and realloc(). This change updates mov.c to only use av_realloc() when allocating memory for AVCodecParameters.extradata. --- libavformat/mov.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) + memset(st->codecpar->extradata, 0, size); st->codecpar->extradata_size = ALAC_EXTRADATA_SIZE; AV_WB32(st->codecpar->extradata , ALAC_EXTRADATA_SIZE); AV_WB32(st->codecpar->extradata + 4, MKTAG('a','l','a','c')); @@ -2054,6 +2055,8 @@ static int mov_rewrite_dvd_sub_extradata(AVStream *st) char buf[256] = {0}; uint8_t *src = st->codecpar->extradata; int i; + uint64_t size; + int ret; if (st->codecpar->extradata_size != 64) return 0; @@ -2075,9 +2078,9 @@ static int mov_rewrite_dvd_sub_extradata(AVStream *st) av_freep(&st->codecpar->extradata); st->codecpar->extradata_size = 0; - st->codecpar->extradata = av_mallocz(strlen(buf) + AV_INPUT_BUFFER_PADDING_SIZE); - if (!st->codecpar->extradata) - return AVERROR(ENOMEM); + size = strlen(buf) + AV_INPUT_BUFFER_PADDING_SIZE; + if ((ret = av_reallocp(&st->codecpar->extradata, size)) < 0) + return ret; st->codecpar->extradata_size = strlen(buf); memcpy(st->codecpar->extradata, buf, st->codecpar->extradata_size); @@ -2392,9 +2395,9 @@ static int mov_read_stsd(MOVContext *c, AVIOContext *pb, MOVAtom atom) av_freep(&st->codecpar->extradata); st->codecpar->extradata_size = sc->extradata_size[0]; if (sc->extradata_size[0]) { - st->codecpar->extradata = av_mallocz(sc->extradata_size[0] + AV_INPUT_BUFFER_PADDING_SIZE); - if (!st->codecpar->extradata) - return AVERROR(ENOMEM); + uint64_t size = sc->extradata_size[0] + AV_INPUT_BUFFER_PADDING_SIZE; + if ((ret = av_reallocp(&st->codecpar->extradata, size)) < 0) + return ret; memcpy(st->codecpar->extradata, sc->extradata[0], sc->extradata_size[0]); } From 1e34019d625d4b33a1767af70bc6c7e2c6b42a7f Mon Sep 17 00:00:00 2001 From: John Rummell Date: Wed, 21 Jun 2017 14:39:20 -0700 Subject: [PATCH] libavformat/mov: Always use av_realloc() for AVCodecParameters.extradata Chromium uses tcmalloc which doesn't like mixing calls to posix_memalign() and realloc(). This change updates mov.c to only use av_realloc() when allocating memory for AVCodecParameters.extradata. --- libavformat/mov.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 876f48d912..6e226c8ce4 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1652,9 +1652,10 @@ static int mov_read_wave(MOVContext *c, AVIOContext *pb, MOVAtom atom) atom.size += 8; } else if (!st->codecpar->extradata_size) { #define ALAC_EXTRADATA_SIZE 36 - st->codecpar->extradata = av_mallocz(ALAC_EXTRADATA_SIZE + AV_INPUT_BUFFER_PADDING_SIZE); - if (!st->codecpar->extradata) - return AVERROR(ENOMEM); + uint64_t size = ALAC_EXTRADATA_SIZE + AV_INPUT_BUFFER_PADDING_SIZE; + if ((ret = av_reallocp(&st->codecpar->extradata, size)) < 0) + return ret; + memset(st->codecpar->extradata, 0, size); st->codecpar->extradata_size = ALAC_EXTRADATA_SIZE; AV_WB32(st->codecpar->extradata , ALAC_EXTRADATA_SIZE); AV_WB32(st->codecpar->extradata + 4, MKTAG('a','l','a','c')); @@ -2054,6 +2055,8 @@ static int mov_rewrite_dvd_sub_extradata(AVStream *st) char buf[256] = {0}; uint8_t *src = st->codecpar->extradata; int i; + uint64_t size; + int ret; if (st->codecpar->extradata_size != 64) return 0; @@ -2075,9 +2078,9 @@ static int mov_rewrite_dvd_sub_extradata(AVStream *st) av_freep(&st->codecpar->extradata); st->codecpar->extradata_size = 0; - st->codecpar->extradata = av_mallocz(strlen(buf) + AV_INPUT_BUFFER_PADDING_SIZE); - if (!st->codecpar->extradata) - return AVERROR(ENOMEM); + size = strlen(buf) + AV_INPUT_BUFFER_PADDING_SIZE; + if ((ret = av_reallocp(&st->codecpar->extradata, size)) < 0) + return ret; st->codecpar->extradata_size = strlen(buf); memcpy(st->codecpar->extradata, buf, st->codecpar->extradata_size); @@ -2392,9 +2395,9 @@ static int mov_read_stsd(MOVContext *c, AVIOContext *pb, MOVAtom atom) av_freep(&st->codecpar->extradata); st->codecpar->extradata_size = sc->extradata_size[0]; if (sc->extradata_size[0]) { - st->codecpar->extradata = av_mallocz(sc->extradata_size[0] + AV_INPUT_BUFFER_PADDING_SIZE); - if (!st->codecpar->extradata) - return AVERROR(ENOMEM); + uint64_t size = sc->extradata_size[0] + AV_INPUT_BUFFER_PADDING_SIZE; + if ((ret = av_reallocp(&st->codecpar->extradata, size)) < 0) + return ret; memcpy(st->codecpar->extradata, sc->extradata[0], sc->extradata_size[0]); } -- 2.14.1.342.g6490525c54-goog