File 0006-Don-t-overwrite-bad-state-with-seek-error.patch of Package flac.30364

From 3ce4475451d19ea2762c596797f95c8fd0204bf2 Mon Sep 17 00:00:00 2001
From: Martijn van Beurden <mvanb1@gmail.com>
Date: Sat, 13 Aug 2022 16:49:44 +0200
Subject: [PATCH] Don't overwrite bad state with seek error

In case memory allocation fails or decoding is aborted during
seeking, do not overwrite these states with a seek error
---
 src/libFLAC/stream_decoder.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/libFLAC/stream_decoder.c b/src/libFLAC/stream_decoder.c
index 2c4afaa58e40..23a0c8901247 100644
--- a/src/libFLAC/stream_decoder.c
+++ b/src/libFLAC/stream_decoder.c
@@ -3360,6 +3360,11 @@ FLAC__bool seek_to_absolute_sample_(FLAC__StreamDecoder *decoder, FLAC__uint64 s
 
 	decoder->private_->target_sample = target_sample;
 	while(1) {
+		/* check whether decoder is still valid so bad state isn't overwritten
+		 * with seek error */
+		if(decoder->protected_->state == FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR ||
+		   decoder->protected_->state == FLAC__STREAM_DECODER_ABORTED)
+			return false;
 		/* check if the bounds are still ok */
 		if (lower_bound_sample >= upper_bound_sample || lower_bound > upper_bound) {
 			decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR;
-- 
2.35.3

openSUSE Build Service is sponsored by