From patchwork Tue Feb 8 18:26:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 34188 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp1044898iov; Tue, 8 Feb 2022 10:26:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJzuK3LAk5ba/Q0JwGORarYhc+jhI7JQRmizThZLAAqiqtuLXLCgFkIbbLSBYQS2UCJqbAAx X-Received: by 2002:a05:6402:27d0:: with SMTP id c16mr1699257ede.276.1644344789648; Tue, 08 Feb 2022 10:26:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644344789; cv=none; d=google.com; s=arc-20160816; b=XYBOT56U3T6pOndEUZ+EnqcxmCRm52hDcyZNzKpZMAQFt52ylb5mh/EAZEkiFNke56 BoWTqsQkGvQGkyFxspwDflAzmctZKRz15oPSzv0FclLklmwJQJd+2qnWpmhGuHrW0ata 8m/6/Z3DQy6rYU4QV1zu2xpxj1xZZZaK5UApVGZic5XCxlq5YgOSJsJ5TKI7vq/ZX4ew MN4lrHy/hGzhmcOLwmxVvv0Wv83pNi1K+zhASbZuwJwqdLWXeViUVxKmOqSN86wA6+zj nU5euTl4+voRH1o0IeLzbvlY9zxsdbIbWHG89dC8d8XFCZx1Qe/KBrd7OlqJ5ual0Svw odtA== 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:mime-version:message-id:date:to:from :delivered-to; bh=GhaQX+zkiCS5PedLz89eblJgcj6q0sb/5qX7zSboFRs=; b=X8PuKpPRswAHzAbmd2nDsgWB1am8OJ3vvdurezX7xHdqPgZvu5lfIADZ825LrMLq0I 46wFO0lt5E2kv9P9xKYG09wlm6AC9omBoH2NsgwSHRIHj4uHLlFz59TTOfdli4SFrYNc oan55NnY7lMi7R5GCsebDzzzm82476sjp2euJ0mYPRBGy6a/Vt61LxCPlT2TotS9vY2i V6aScJPQrmf3KEKNChfrWvNwBTo1N9ezmtq/S3iuKeOp3p+Ffm+Z8JiyPdbkbTq4JCgd MNI/llK847wcmsdTaAVNGeceBjUscZLnI1eZU/i7dO1t3e2aIa3TPjTXaBJPyOWmHDKg JxOg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id hp3si10871350ejc.847.2022.02.08.10.26.28; Tue, 08 Feb 2022 10:26:29 -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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9573768B120; Tue, 8 Feb 2022 20:26:25 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CB92868AEAA for ; Tue, 8 Feb 2022 20:26:18 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 424C624017C for ; Tue, 8 Feb 2022 19:26:18 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id xlyGBwEE72i9 for ; Tue, 8 Feb 2022 19:26:16 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id E780E240175 for ; Tue, 8 Feb 2022 19:26:16 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id DCDFA3A06CD; Tue, 8 Feb 2022 19:26:16 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Tue, 8 Feb 2022 19:26:13 +0100 Message-Id: <20220208182614.25504-1-anton@khirnov.net> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] lavu/fifo: fix a corner case in av_fifo_grow2() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: 1ojvZe7OsaBG When the fifo is grown by exactly the current write offset, it would end up with offset_w = nb_elems. If av_fifo_write_from_cb() is called in such a state, the user callback would get callled with *nb_elems=0, which will then cause the write to return without writing anything. --- libavutil/fifo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/fifo.c b/libavutil/fifo.c index 0af0154945..2af8842cc5 100644 --- a/libavutil/fifo.c +++ b/libavutil/fifo.c @@ -115,7 +115,7 @@ int av_fifo_grow2(AVFifo *f, size_t inc) (f->offset_w - copy) * f->elem_size); f->offset_w -= copy; } else - f->offset_w = f->nb_elems + copy; + f->offset_w = copy == inc ? 0 : f->nb_elems + copy; } f->nb_elems += inc;