Skip to content

Commit 85bc4dc

Browse files
committed
FIX: removed <ctype.h> dependency in PNG codec
1 parent 7717d75 commit 85bc4dc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/core/u-png.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939

4040
#include "sys-core.h"
4141
#include "sys-zlib.h"
42-
#include <ctype.h> // remove this later !!!!
4342

4443
#if defined(ENDIAN_LITTLE)
4544
#define CVT_END_L(a) a=(a<<24)|(((a>>8)&255)<<16)|(((a>>16)&255)<<8)|(a>>24)
@@ -50,6 +49,7 @@
5049
#endif
5150

5251
#define int_abs(a) (((a)<0)?(-(a)):(a))
52+
#define not_alpha(c) (c<'A' || c>'z' || (c>'Z' && c<'a')) // used to validate PNG chunk ID
5353

5454
/**********************************************************************/
5555

@@ -148,7 +148,7 @@ static unsigned char *get_chunk(unsigned char **bufp,int *np,char *type,int *len
148148
while(1) {
149149
if(n<12)
150150
trap_png();
151-
if((!isalpha(p[4]))||(!isalpha(p[5]))||(!isalpha(p[6]))||(!isalpha(p[7])))
151+
if((not_alpha(p[4]))||(not_alpha(p[5]))||(not_alpha(p[6]))||(not_alpha(p[7])))
152152
trap_png();
153153
memcpy(&len,p,4);
154154
CVT_END_L(len);

0 commit comments

Comments
 (0)