shithub: rgbds

Download patch

ref: 5ea8490e2b07a110f1aacc8079c850d70cb90058
parent: 40f8e33e6cc293498c3e3ad53c534ebf66d262ac
parent: 5863cd10b85c49fa0e3b2a1dd0997f0db7bde26b
author: Eldred Habert <[email protected]>
date: Wed Apr 8 19:35:21 EDT 2020

Merge pull request #507 from JL2210/null-pointer-fix-1

Fix possible null pointer dereference

--- a/src/asm/lexer.c
+++ b/src/asm/lexer.c
@@ -254,7 +254,7 @@
 	else if (capacity == 0)
 		capacity = 1;
 
-	while (!feof(f)) {
+	do {
 		if (buf == NULL || size >= capacity) {
 			if (buf)
 				capacity *= 2;
@@ -273,7 +273,7 @@
 			fatalerror("%s: fread error", __func__);
 
 		size += read_count;
-	}
+	} while (!feof(f));
 
 	pBuffer->pBufferRealStart = buf;
 	pBuffer->pBufferStart = buf + SAFETYMARGIN;