Skip to content

Commit 1e7dc3a

Browse files
committed
pdfext: do not use non-POSIX memrchr()
Reported by Dirk-Wilhelm Peters <[email protected]>.
1 parent 90d1d12 commit 1e7dc3a

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

pdfext.c

+10-3
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,20 @@ int pdf_lval(char *pdf, int len, int pos, int idx)
174174
return -1;
175175
}
176176

177-
void *memrchr(void *m, int c, long n);
177+
static void *my_memrchr(void *m, int c, long n)
178+
{
179+
int i;
180+
for (i = 0; i < n; i++)
181+
if (*(unsigned char *) (m + n - 1 - i) == c)
182+
return m + n - 1 - i;
183+
return NULL;
184+
}
178185

179186
static int prevline(char *pdf, int len, int off)
180187
{
181-
char *nl = memrchr(pdf, '\n', off);
188+
char *nl = my_memrchr(pdf, '\n', off);
182189
if (nl && nl > pdf) {
183-
char *nl2 = memrchr(pdf, '\n', nl - pdf -1);
190+
char *nl2 = my_memrchr(pdf, '\n', nl - pdf - 1);
184191
if (nl2)
185192
return nl2 - pdf + 1;
186193
}

0 commit comments

Comments
 (0)