From 64105057d03df64841e3aaaaf05e84c069969f55 Mon Sep 17 00:00:00 2001
From: zhailiangliang <zhailiangliang@loongson.cn>
Date: Thu, 20 Apr 2023 20:06:20 +0800
Subject: [PATCH] fix runtime error: applying zero offset to null pointer

Reference:https://gitlab.com/libtiff/libtiff/-/merge_requests/479/diffs
Conflict:Adaptation Context

---
 libtiff/tif_dir.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libtiff/tif_dir.c b/libtiff/tif_dir.c
index 349dfe4..8a9ac7d 100644
--- a/libtiff/tif_dir.c
+++ b/libtiff/tif_dir.c
@@ -145,10 +145,10 @@ static uint16_t
 countInkNamesString(TIFF *tif, uint32_t slen, const char *s)
 {
 	uint16_t i = 0;
-	const char *ep = s + slen;
-	const char *cp = s;
 
 	if (slen > 0) {
+		const char *ep = s + slen;
+		const char *cp = s;
 		do {
 			for (; cp < ep && *cp != '\0'; cp++) {}
 			if (cp >= ep)
-- 
2.27.0

