From patchwork Sun Nov 10 18:04:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 16196 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 0A083448FA5 for ; Sun, 10 Nov 2019 20:05:09 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C481668AE27; Sun, 10 Nov 2019 20:05:08 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D71BD68A3BB for ; Sun, 10 Nov 2019 20:05:01 +0200 (EET) Received: by mail-wm1-f65.google.com with SMTP id u18so3362347wmc.3 for ; Sun, 10 Nov 2019 10:05:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oNC6qs/Xbqk6DVoHF0+cCHYpVjXrxQ1Wc1uFUGpO7aE=; b=gVDz4/hbJsgl8ryzqbjKpCVIBtL+qIcHduJhuBa/mCXP5nFIApaRigqEs88YJftPSQ o+938sli4DLXLAfAWhf0JR77fch+cwNWpvI0SD6sZ10bRAKXL7/TdcQZ52Ws7EZWj1v3 3ETfC+/QCbrVykSgXGz6L+DcFlWcPqiMIcASxZ/ry8othWnSik3iy+KCrd1/WowgM7sU gXGZvifB7vHIc68KPUaFJA9IrmnAcD5WKgn0RuBnRyn3J7biA69wFhAaYPmznEzZoLEH fl+DuFlNHtCMN7DEvyOr+KXyx2SBqGqG/2MrWvyg7q22Lh4PbBUMd0HYKIxwzvwksILu uWtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oNC6qs/Xbqk6DVoHF0+cCHYpVjXrxQ1Wc1uFUGpO7aE=; b=KsIPylv12NF08xNb4Rek82Qr9HWx9hFu0IonyNkz8teoHR4QBc6jX/VL5VepW/wzAy ClRIOi7TNgjk+vdqXsaCrRSVhMNuADHWHQVeN/S2bUQurJjneUaII5/u4tywLG0wzl5J Bdp9jjiCprL/zBPPWiEidVOicSxvepCl0MKIkNa1TZpPDDXSZKcEduEthOQnnRzEy12E 75FXE+8aa5oGdYhckcHA+XnkRmAMvREHI78JvPEO85EruUCf4ANP1m1/hQl7kMs0XKF3 jVttCNuNxqmUa60sdbcFdv6T2CeAm/qGikmQcY8Q3EwUnb6Ga7R7jGp59E7FJp7OYBGC T39A== X-Gm-Message-State: APjAAAUdwQorzyXiIlY+QHgCIgmf7pdV2e69Bx1Irnm2VASUQZ59roHM BOt/InfyFM4x3dXuU5Ei/EDT0mJ4 X-Google-Smtp-Source: APXvYqxv217kUV59qtUtN0mlv2m5RZ2xvTY8t1KGtxhPfdxXW6xv3xPCd8srDSGmBKeTcC12ZmfsMQ== X-Received: by 2002:a1c:a404:: with SMTP id n4mr16691982wme.135.1573409101159; Sun, 10 Nov 2019 10:05:01 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc08937.dynamic.kabel-deutschland.de. [188.192.137.55]) by smtp.gmail.com with ESMTPSA id v184sm17327664wme.31.2019.11.10.10.04.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Nov 2019 10:05:00 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 10 Nov 2019 19:04:51 +0100 Message-Id: <20191110180451.31708-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191110035406.11500-1-andreas.rheinhardt@gmail.com> References: <20191110035406.11500-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avformat/id3v2: Avoid av_strdup for key and value of dict 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Andreas Rheinhardt --- libavformat/id3v2.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c index e9843eef9a..abe073dcc1 100644 --- a/libavformat/id3v2.c +++ b/libavformat/id3v2.c @@ -361,8 +361,8 @@ static void read_uslt(AVFormatContext *s, AVIOContext *pb, int taglen, { uint8_t lang[4]; uint8_t *descriptor = NULL; // 'Content descriptor' - uint8_t *text = NULL; - char *key = NULL; + uint8_t *text; + char *key; int encoding; int ok = 0; @@ -387,18 +387,19 @@ static void read_uslt(AVFormatContext *s, AVIOContext *pb, int taglen, key = av_asprintf("lyrics-%s%s%s", descriptor[0] ? (char *)descriptor : "", descriptor[0] ? "-" : "", lang); - if (!key) + if (!key) { + av_free(text); goto error; + } - av_dict_set(metadata, key, text, 0); + av_dict_set(metadata, key, text, + AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL); ok = 1; error: if (!ok) av_log(s, AV_LOG_ERROR, "Error reading lyrics, skipped\n"); av_free(descriptor); - av_free(text); - av_free(key); } /**