diff options
author | Juan Linietsky <reduzio@gmail.com> | 2016-06-20 22:38:31 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2016-06-20 22:38:31 -0300 |
commit | 9b8f2741aee4604bd7a84ac746fae58ae06a4267 (patch) | |
tree | 3ea3ee6686738223b1d54638dfff4fc67617093b /tools/editor/plugins/sample_editor_plugin.cpp | |
parent | fa0d1cd27cac45534097219b52a5b7ab08e1b917 (diff) |
do not crash when generating preview of very large sound files, fixes #4123
Diffstat (limited to 'tools/editor/plugins/sample_editor_plugin.cpp')
-rw-r--r-- | tools/editor/plugins/sample_editor_plugin.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/tools/editor/plugins/sample_editor_plugin.cpp b/tools/editor/plugins/sample_editor_plugin.cpp index a3891a648b..b094184a29 100644 --- a/tools/editor/plugins/sample_editor_plugin.cpp +++ b/tools/editor/plugins/sample_editor_plugin.cpp @@ -211,7 +211,7 @@ void SampleEditor::generate_preview_texture(const Ref<Sample>& p_sample,Ref<Imag for(int j=0;j<h;j++) { float v = (j/(float)h) * 2.0 - 1.0; - uint8_t* imgofs = &imgw[(j*w+i)*3]; + uint8_t* imgofs = &imgw[(uint64_t(j)*w+i)*3]; if (v>min[0] && v<max[0]) { imgofs[0]=255; imgofs[1]=150; @@ -229,8 +229,8 @@ void SampleEditor::generate_preview_texture(const Ref<Sample>& p_sample,Ref<Imag 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; @@ -241,7 +241,7 @@ void SampleEditor::generate_preview_texture(const Ref<Sample>& p_sample,Ref<Imag 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<min[j]) @@ -257,7 +257,7 @@ void SampleEditor::generate_preview_texture(const Ref<Sample>& p_sample,Ref<Imag 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<min[j]) @@ -270,7 +270,7 @@ void SampleEditor::generate_preview_texture(const Ref<Sample>& p_sample,Ref<Imag if (!stereo) { for(int j=0;j<h;j++) { float v = (j/(float)h) * 2.0 - 1.0; - uint8_t* imgofs = &imgw[(j*w+i)*3]; + uint8_t* imgofs = &imgw[(uint64_t(j)*w+i)*3]; if (v>min[0] && v<max[0]) { imgofs[0]=255; imgofs[1]=150; @@ -297,7 +297,7 @@ void SampleEditor::generate_preview_texture(const Ref<Sample>& p_sample,Ref<Imag v = ((j-(h/2))/(float)(h/2)) * 2.0 - 1.0; } - uint8_t* imgofs = &imgw[(j*w+i)*3]; + uint8_t* imgofs = &imgw[(uint64_t(j)*w+i)*3]; if (v>min[half] && v<max[half]) { imgofs[0]=255; imgofs[1]=150; |