From db27a6b9403d911f76345ecd04f53a3e29aad0ea Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Wed, 13 Jul 2016 14:40:18 +0900 Subject: [PATCH] pdf: Fix page index and The module was not able to load any PDF with a single page (since the index starts from 0, not 1 as it was assumed). Also, fix a CID where Coverity was very very right. Fixes CID 1356608: The operaton may have an undefined behavior or yield to an unexpected result. In poppler_load_image(int, int): A bit shift operation has a shift amount which is too large or has a negative value. --- src/generic/evas/pdf/main.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/generic/evas/pdf/main.cpp b/src/generic/evas/pdf/main.cpp index 85edf49ce6..097f057b05 100644 --- a/src/generic/evas/pdf/main.cpp +++ b/src/generic/evas/pdf/main.cpp @@ -67,7 +67,7 @@ Eina_Bool poppler_init(const char *file, int page_nbr, int size_w, int size_h) /* load the page */ - doc_page = doc->create_page(page_nbr + 1); + doc_page = doc->create_page(page_nbr); if (!doc_page) goto del_pdfdoc; @@ -149,6 +149,9 @@ void poppler_load_image(int size_w EINA_UNUSED, int size_h EINA_UNUSED) for (y = 0; y < crop_height; y++) \ for (x = 0; x < crop_width; x++) +#define ARGB_JOIN(a,r,g,b) \ + (((a) << 24) + ((r) << 16) + ((g) << 8) + (b)) + if (out.format() == image::format_mono) { //FIXME no idea what this format is like @@ -159,12 +162,8 @@ void poppler_load_image(int size_w EINA_UNUSED, int size_h EINA_UNUSED) src = (RGB24*) out.data(); IMAGE_PIXEL_ITERATOR { - DATA32 d = 0xFF000000; int pos = x+y*crop_width; - d |= src[pos][0] >> 8; - d |= src[pos][1] >> 16; - d |= src[pos][2] >> 24; - dst[pos] = d; + dst[pos] = ARGB_JOIN(0xFF, src[pos][0], src[pos][1], src[pos][2]); } } else if (out.format() == image::format_argb32)