diff --git a/src/xpdev/str_list.c b/src/xpdev/str_list.c
index a6bb11ea68e25ce6277ea1487a1ae282b2a9b0e9..f9331780969b78ab8d74d304f8075e0d2dcb6c5b 100644
--- a/src/xpdev/str_list.c
+++ b/src/xpdev/str_list.c
@@ -664,7 +664,8 @@ str_list_t strListReadFile(FILE* fp, str_list_t* lp, size_t max_line_len)
 
 			if (fgets(buf, max_line_len + 1, fp) == NULL)
 				break;
-			strListAppend(lp, buf, count++);
+			if (strListAppend(lp, buf, count++) == NULL)
+				break;
 		}
 		if (!feof(fp)) {
 			strListFreeStrings(list);