summaryrefslogtreecommitdiff
path: root/src/generic
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2016-07-13 14:40:18 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-07-13 15:04:47 +0900
commitdb27a6b9403d911f76345ecd04f53a3e29aad0ea (patch)
treed2f456cf763c604296efd0832ec4f393dfb56ddf /src/generic
parent3d16cdc67e66642e12279edeb5c90438e9dc7f21 (diff)
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.
Diffstat (limited to 'src/generic')
-rw-r--r--src/generic/evas/pdf/main.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/generic/evas/pdf/main.cpp b/src/generic/evas/pdf/main.cpp
index 85edf49..097f057 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)
67 67
68 /* load the page */ 68 /* load the page */
69 69
70 doc_page = doc->create_page(page_nbr + 1); 70 doc_page = doc->create_page(page_nbr);
71 if (!doc_page) 71 if (!doc_page)
72 goto del_pdfdoc; 72 goto del_pdfdoc;
73 73
@@ -149,6 +149,9 @@ void poppler_load_image(int size_w EINA_UNUSED, int size_h EINA_UNUSED)
149 for (y = 0; y < crop_height; y++) \ 149 for (y = 0; y < crop_height; y++) \
150 for (x = 0; x < crop_width; x++) 150 for (x = 0; x < crop_width; x++)
151 151
152#define ARGB_JOIN(a,r,g,b) \
153 (((a) << 24) + ((r) << 16) + ((g) << 8) + (b))
154
152 if (out.format() == image::format_mono) 155 if (out.format() == image::format_mono)
153 { 156 {
154 //FIXME no idea what this format is like 157 //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)
159 src = (RGB24*) out.data(); 162 src = (RGB24*) out.data();
160 IMAGE_PIXEL_ITERATOR 163 IMAGE_PIXEL_ITERATOR
161 { 164 {
162 DATA32 d = 0xFF000000;
163 int pos = x+y*crop_width; 165 int pos = x+y*crop_width;
164 d |= src[pos][0] >> 8; 166 dst[pos] = ARGB_JOIN(0xFF, src[pos][0], src[pos][1], src[pos][2]);
165 d |= src[pos][1] >> 16;
166 d |= src[pos][2] >> 24;
167 dst[pos] = d;
168 } 167 }
169 } 168 }
170 else if (out.format() == image::format_argb32) 169 else if (out.format() == image::format_argb32)