summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2022-11-14 18:29:57 +0100
committerRémi Verschelde <rverschelde@gmail.com>2022-11-14 18:29:57 +0100
commit19ae37cc99dfc236dbe5a520d3147353d7cfe8ff (patch)
tree90044d9861b32f5b33ce0791aaf71d85340ea36d
parent7dafe06e27ebf211160938229bad4aabf58e3272 (diff)
parent9a666a9275ede73d24cd86e37ac2e324af65eca9 (diff)
Merge pull request #68626 from AleCamara/bug-66928-crash-preview-short-mp3
Fix editor crash on audio preview
-rw-r--r--editor/audio_stream_preview.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/editor/audio_stream_preview.cpp b/editor/audio_stream_preview.cpp
index b9e52ad7ad..f99025ad06 100644
--- a/editor/audio_stream_preview.cpp
+++ b/editor/audio_stream_preview.cpp
@@ -42,6 +42,10 @@ float AudioStreamPreview::get_max(float p_time, float p_time_next) const {
}
int max = preview.size() / 2;
+ if (max == 0) {
+ return 0;
+ }
+
int time_from = p_time / length * max;
int time_to = p_time_next / length * max;
time_from = CLAMP(time_from, 0, max - 1);
@@ -69,6 +73,10 @@ float AudioStreamPreview::get_min(float p_time, float p_time_next) const {
}
int max = preview.size() / 2;
+ if (max == 0) {
+ return 0;
+ }
+
int time_from = p_time / length * max;
int time_to = p_time_next / length * max;
time_from = CLAMP(time_from, 0, max - 1);