From 9b8f2741aee4604bd7a84ac746fae58ae06a4267 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Mon, 20 Jun 2016 22:38:31 -0300 Subject: [PATCH] do not crash when generating preview of very large sound files, fixes #4123 --- tools/editor/plugins/editor_preview_plugins.cpp | 10 +++++----- tools/editor/plugins/sample_editor_plugin.cpp | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tools/editor/plugins/editor_preview_plugins.cpp b/tools/editor/plugins/editor_preview_plugins.cpp index f5470451ba0..a057e6c2a1e 100644 --- a/tools/editor/plugins/editor_preview_plugins.cpp +++ b/tools/editor/plugins/editor_preview_plugins.cpp @@ -669,7 +669,7 @@ Ref EditorSamplePreviewPlugin::generate(const RES& p_from) { for(int j=0;jmin[0] && v EditorSamplePreviewPlugin::generate(const RES& p_from) { float max[2]={-1e10,-1e10}; float min[2]={1e10,1e10}; int c=stereo?2:1; - int from = i*len/w; - int to = (i+1)*len/w; + int from = uint64_t(i)*len/w; + int to = (uint64_t(i)+1)*len/w; if (to>=len) to=len-1; @@ -699,7 +699,7 @@ Ref EditorSamplePreviewPlugin::generate(const RES& p_from) { for(int k=from;k<=to;k++) { - float v = src[k*c+j]/32768.0; + float v = src[uint64_t(k)*c+j]/32768.0; if (v>max[j]) max[j]=v; if (v EditorSamplePreviewPlugin::generate(const RES& p_from) { for(int k=from;k<=to;k++) { - float v = src[k*c+j]/128.0; + float v = src[uint64_t(k)*c+j]/128.0; if (v>max[j]) max[j]=v; if (v& p_sample,Refmin[0] && v& p_sample,Ref=len) to=len-1; @@ -241,7 +241,7 @@ void SampleEditor::generate_preview_texture(const Ref& p_sample,Refmax[j]) max[j]=v; if (v& p_sample,Refmax[j]) max[j]=v; if (v& p_sample,Refmin[0] && v& p_sample,Refmin[half] && v