From b563039b8fb6b26804a13180efee83f892b6c939 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 27 Aug 2012 09:01:34 +0000 Subject: Sequencer: fix crash of histogram view for float images Overexposured pixels lead to wrong memory access in histogram making function --- source/blender/editors/space_sequencer/sequencer_scopes.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source') diff --git a/source/blender/editors/space_sequencer/sequencer_scopes.c b/source/blender/editors/space_sequencer/sequencer_scopes.c index 5debeaf79ae..6f460500bc4 100644 --- a/source/blender/editors/space_sequencer/sequencer_scopes.c +++ b/source/blender/editors/space_sequencer/sequencer_scopes.c @@ -470,7 +470,7 @@ static ImBuf *make_histogram_view_from_ibuf_byte(ImBuf *ibuf) unsigned int bins[3][256]; - memset(bins, 0, 3 * 256 * sizeof(unsigned int)); + memset(bins, 0, sizeof(bins)); for (y = 0; y < ibuf->y; y++) { for (x = 0; x < ibuf->x; x++) { @@ -507,10 +507,10 @@ static ImBuf *make_histogram_view_from_ibuf_byte(ImBuf *ibuf) static int get_bin_float(float f) { if (f < -0.25f) { - f = -0.25f; + return 0; } - else if (f > 1.25f) { - f = 1.25f; + else if (f >= 1.25f) { + return 511; } return (int) (((f + 0.25f) / 1.5f) * 512); @@ -524,7 +524,7 @@ static ImBuf *make_histogram_view_from_ibuf_float(ImBuf *ibuf) unsigned int bins[3][512]; - memset(bins, 0, 3 * 256 * sizeof(unsigned int)); + memset(bins, 0, sizeof(bins)); for (y = 0; y < ibuf->y; y++) { for (x = 0; x < ibuf->x; x++) { -- cgit v1.2.3