summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2018-05-21 11:09:17 +0200
committerTor Andersson <tor.andersson@artifex.com>2018-06-02 02:08:17 +0200
commit928b43eab613970ebe6448b294bba866d43d12bd (patch)
tree45febe0455ee90abeb1398c62e7e68c85e050209 /source
parent4d473e7f6a6ec72265270c03a26b48e27db11282 (diff)
downloadmupdf-928b43eab613970ebe6448b294bba866d43d12bd.tar.xz
Add a fz_strnlen function (strnlen is not standard C).
Diffstat (limited to 'source')
-rw-r--r--source/fitz/load-png.c2
-rw-r--r--source/fitz/string.c7
2 files changed, 8 insertions, 1 deletions
diff --git a/source/fitz/load-png.c b/source/fitz/load-png.c
index 39c4ea81..cf1ab536 100644
--- a/source/fitz/load-png.c
+++ b/source/fitz/load-png.c
@@ -347,7 +347,7 @@ png_read_icc(fz_context *ctx, struct info *info, const unsigned char *p, unsigne
fz_stream *mstm = NULL, *zstm = NULL;
fz_colorspace *cs = NULL;
size_t m = fz_mini(80, size);
- size_t n = strnlen((const char *)p, m);
+ size_t n = fz_strnlen((const char *)p, m);
if (n + 2 > m)
{
fz_warn(ctx, "invalid ICC profile name");
diff --git a/source/fitz/string.c b/source/fitz/string.c
index dbcc2c22..a014ce89 100644
--- a/source/fitz/string.c
+++ b/source/fitz/string.c
@@ -14,6 +14,13 @@ fz_tolower(int c)
return c;
}
+size_t
+fz_strnlen(const char *s, size_t n)
+{
+ const char *p = memchr(s, 0, n);
+ return p ? p - s : n;
+}
+
int
fz_strcasecmp(const char *a, const char *b)
{