From 49a74b371c322a1e55e242a230a7bb577ebe065b Mon Sep 17 00:00:00 2001
From: Marcus Meissner <marcus@jet.franken.de>
Date: Mon, 6 Sep 2021 08:42:56 +0200
Subject: [PATCH] replace tail recursion by direct loop, in case the compiler
 does not translate it into a tail recursion it could be used to cause stack
 overruns (oss-fuzz)

---
 libexif/exif-loader.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libexif/exif-loader.c b/libexif/exif-loader.c
index e376465..5c48faf 100644
--- a/libexif/exif-loader.c
+++ b/libexif/exif-loader.c
@@ -154,6 +154,7 @@ exif_loader_write (ExifLoader *eld, unsigned char *buf, unsigned int len)
 {
 	unsigned int i;
 
+begin:
 	if (!eld || (len && !buf)) 
 		return 0;
 
@@ -310,7 +311,7 @@ exif_loader_write (ExifLoader *eld, unsigned char *buf, unsigned int len)
 	 * to read all data we need. Fill it with new data.
 	 */
 	eld->b_len = 0;
-	return exif_loader_write (eld, buf, len);
+	goto begin;
 }
 
 ExifLoader *
-- 
2.27.0
