From a4d2afffa54ae45abb2641b5b92ffa84adbf89c9 Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Thu, 1 Jun 2006 21:53:01 +0000
Subject: [PATCH] Added NULL fp checking str_list_read_file().

---
 src/xpdev/str_list.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/src/xpdev/str_list.c b/src/xpdev/str_list.c
index 80725017b6..77841f7a1e 100644
--- a/src/xpdev/str_list.c
+++ b/src/xpdev/str_list.c
@@ -8,7 +8,7 @@
  * @format.tab-size 4		(Plain Text/Source Code File Header)			*
  * @format.use-tabs true	(see http://www.synchro.net/ptsc_hdr.html)		*
  *																			*
- * Copyright 2005 Rob Swindell - http://www.synchro.net/copyright.html		*
+ * Copyright 2006 Rob Swindell - http://www.synchro.net/copyright.html		*
  *																			*
  * This library is free software; you can redistribute it and/or			*
  * modify it under the terms of the GNU Lesser General Public License		*
@@ -373,14 +373,16 @@ static str_list_t str_list_read_file(FILE* fp, str_list_t* lp, size_t max_line_l
 		lp=&list;
 	}
 
-	count=strListCount(*lp);
-	while(!feof(fp)) {
-		if(buf==NULL && (buf=(char*)alloca(max_line_len+1))==NULL)
-			return(NULL);
-		
-		if(fgets(buf,max_line_len+1,fp)==NULL)
-			break;
-		strListAppend(lp, buf, count++);
+	if(fp!=NULL) {
+		count=strListCount(*lp);
+		while(!feof(fp)) {
+			if(buf==NULL && (buf=(char*)alloca(max_line_len+1))==NULL)
+				return(NULL);
+			
+			if(fgets(buf,max_line_len+1,fp)==NULL)
+				break;
+			strListAppend(lp, buf, count++);
+		}
 	}
 
 	return(*lp);
-- 
GitLab