[vlc-commits] [Git][videolan/vlc][master] contrib: gme: backport assert patch
Steve Lhomme (@robUx4)
gitlab at videolan.org
Thu May 16 16:50:54 UTC 2024
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
8205482c by Thomas Guillem at 2024-05-16T15:31:41+00:00
contrib: gme: backport assert patch
assert() may be disabled and you don't want to abort a whole process in
case of a parsing issue. So check the offset from samples_avail(), that
will return 0 (EOF) in case of a out of bounds read.
Patch already upstream.
- - - - -
2 changed files:
- + contrib/src/gme/0004-Blip_Buffer-replace-assert-with-a-check.patch
- contrib/src/gme/rules.mak
Changes:
=====================================
contrib/src/gme/0004-Blip_Buffer-replace-assert-with-a-check.patch
=====================================
@@ -0,0 +1,45 @@
+From 74449b553fef6528e1fd9d2dccc6413ded1d5e39 Mon Sep 17 00:00:00 2001
+From: Thomas Guillem <thomas at gllm.fr>
+Date: Wed, 15 May 2024 14:34:59 +0200
+Subject: [PATCH] Blip_Buffer: replace assert with a check
+
+assert() may be disabled and you don't want to abort a whole process in
+case of a parsing issue. So check the offset from samples_avail(), that
+will return 0 (EOF) in case of a out of bounds read.
+---
+ gme/Blip_Buffer.cpp | 1 -
+ gme/Blip_Buffer.h | 6 +++++-
+ 2 files changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/gme/Blip_Buffer.cpp b/gme/Blip_Buffer.cpp
+index 71e48b2..7d2faf3 100644
+--- a/gme/Blip_Buffer.cpp
++++ b/gme/Blip_Buffer.cpp
+@@ -144,7 +144,6 @@ void Blip_Buffer::bass_freq( int freq )
+ void Blip_Buffer::end_frame( blip_time_t t )
+ {
+ offset_ += t * factor_;
+- assert( samples_avail() <= (long) buffer_size_ ); // time outside buffer length
+ }
+
+ void Blip_Buffer::remove_silence( long count )
+diff --git a/gme/Blip_Buffer.h b/gme/Blip_Buffer.h
+index 9af53f7..ea109d7 100644
+--- a/gme/Blip_Buffer.h
++++ b/gme/Blip_Buffer.h
+@@ -475,7 +475,11 @@ inline blip_eq_t::blip_eq_t( double t, long rf, long sr, long cf ) :
+ treble( t ), rolloff_freq( rf ), sample_rate( sr ), cutoff_freq( cf ) { }
+
+ inline int Blip_Buffer::length() const { return length_; }
+-inline long Blip_Buffer::samples_avail() const { return (long) (offset_ >> BLIP_BUFFER_ACCURACY); }
++inline long Blip_Buffer::samples_avail() const
++{
++ long samples = (long) (offset_ >> BLIP_BUFFER_ACCURACY);
++ return samples <= (long) buffer_size_ ? samples : 0;
++}
+ inline long Blip_Buffer::sample_rate() const { return sample_rate_; }
+ inline int Blip_Buffer::output_latency() const { return blip_widest_impulse_ / 2; }
+ inline long Blip_Buffer::clock_rate() const { return clock_rate_; }
+--
+2.39.2
+
=====================================
contrib/src/gme/rules.mak
=====================================
@@ -18,6 +18,7 @@ game-music-emu: game-music-emu-$(GME_VERSION).tar.xz .sum-gme
$(APPLY) $(SRC)/gme/0001-Export-the-proper-C-runtime-library.patch
$(APPLY) $(SRC)/gme/0002-link-with-libm-and-set-it-in-pkg-config-when-buildin.patch
$(APPLY) $(SRC)/gme/0003-fix-android-toolchain-broken-CMAKE_CXX_IMPLICIT_LINK.patch
+ $(APPLY) $(SRC)/gme/0004-Blip_Buffer-replace-assert-with-a-check.patch
$(call pkg_static,"gme/libgme.pc.in")
$(MOVE)
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/8205482c3ad8436c244f04b7a09e94b7acf9c66e
--
This project does not include diff previews in email notifications.
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/8205482c3ad8436c244f04b7a09e94b7acf9c66e
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list