ref: 1e7dc3a3cba0ff5539af424ffcd79badcb80ab2c
parent: 90d1d12615657eb7c70cf7ce0d109fac6b5245e0
author: Ali Gholami Rudi <ali@rudi.ir>
date: Thu Apr 19 11:36:25 EDT 2018
pdfext: do not use non-POSIX memrchr() Reported by Dirk-Wilhelm Peters <peters@schwertfisch.de>.
--- a/pdfext.c
+++ b/pdfext.c
@@ -174,13 +174,20 @@
return -1;
}
-void *memrchr(void *m, int c, long n);
+static void *my_memrchr(void *m, int c, long n)
+{
+ int i;
+ for (i = 0; i < n; i++)
+ if (*(unsigned char *) (m + n - 1 - i) == c)
+ return m + n - 1 - i;
+ return NULL;
+}
static int prevline(char *pdf, int len, int off)
{
- char *nl = memrchr(pdf, '\n', off);
+ char *nl = my_memrchr(pdf, '\n', off);
if (nl && nl > pdf) {
- char *nl2 = memrchr(pdf, '\n', nl - pdf -1);
+ char *nl2 = my_memrchr(pdf, '\n', nl - pdf - 1);
if (nl2)
return nl2 - pdf + 1;
}