summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Baptiste Mardelle <jb@kdenlive.org>2016-10-09 11:22:53 (GMT)
committer Jean-Baptiste Mardelle <jb@kdenlive.org>2016-10-09 11:22:53 (GMT)
commit9cad7c579af7ef919a29fc007eaa008466078aec (patch)
treea357713d217caebd3ab08324a9497e172fb5c785
parent80fb75ac46dbbfe7a8902792fab6e7e0d5bfda0f (diff)
Fix cairo mixer image corruption (out of bound RGB values in cairo frei0r_cairo_unpremultiply_rgba)
kdenlive issue 361163
-rw-r--r--include/frei0r_cairo.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/include/frei0r_cairo.h b/include/frei0r_cairo.h
index cffbb0b..fea3b7d 100644
--- a/include/frei0r_cairo.h
+++ b/include/frei0r_cairo.h
@@ -22,6 +22,7 @@
#include <cairo.h>
#include <string.h>
+#include "frei0r_math.h"
/**
* String identifiers for gradient types available using Cairo.
@@ -254,9 +255,9 @@ void frei0r_cairo_unpremultiply_rgba (unsigned char *rgba, int pixels)
while ( --i ) {
register unsigned char a = rgba[3];
if (a != 0) {
- rgba[0] = ( rgba[0] << 8 ) / a;
- rgba[1] = ( rgba[1] << 8 ) / a;
- rgba[2] = ( rgba[2] << 8 ) / a;
+ rgba[0] = MIN(( rgba[0] << 8 ) / a, 255);
+ rgba[1] = MIN(( rgba[1] << 8 ) / a, 255);
+ rgba[2] = MIN(( rgba[2] << 8 ) / a, 255);
}
rgba += 4;
}