about summary refs log tree commit diff stats
path: root/xxxterm.c
diff options
context:
space:
mode:
authorMarco Peereboom <marco@conformal.com>2010-08-10 19:14:41 +0000
committerMarco Peereboom <marco@conformal.com>2010-08-10 19:14:41 +0000
commit0ac7921a8a2e5fb1615bed82f99daf20b84f12a2 (patch)
treed1fc3d5df480a7e968914bf316258a66b0b92af7 /xxxterm.c
parent8e170a3764eefa608f2680d7886a45db75b32582 (diff)
downloadxombrero-0ac7921a8a2e5fb1615bed82f99daf20b84f12a2.tar.gz
plug memleak and more paranoia on file errors
from Aaron Stellman <zion@x96.org>
Diffstat (limited to 'xxxterm.c')
-rw-r--r--xxxterm.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/xxxterm.c b/xxxterm.c
index a6fe625..11030ae 100644
--- a/xxxterm.c
+++ b/xxxterm.c
@@ -337,7 +337,7 @@ config_parse(char *filename)
 {
 	FILE			*config;
 	char			*line, *cp, *var, *val;
-	size_t			 len, lineno = 0;
+	size_t			len, lineno = 0;
 
 	DNPRINTF(XT_D_CONFIG, "config_parse: filename %s\n", filename);
 
@@ -353,7 +353,7 @@ config_parse(char *filename)
 
 	for (;;) {
 		if ((line = fparseln(config, &len, &lineno, NULL, 0)) == NULL)
-			if (feof(config))
+			if (feof(config) || ferror(config))
 				break;
 
 		cp = line;
@@ -490,13 +490,16 @@ favorites(struct tab *t, struct karg *args)
 
 	for (i = 1;;) {
 		if ((title = fparseln(f, &len, &lineno, NULL, 0)) == NULL)
-			if (feof(f))
+			if (feof(f) || ferror(f))
 				break;
-		if (strlen(title) == 0)
+		if (len == 0) {
+			free(title);
+			title = NULL;
 			continue;
+		}
 
 		if ((uri = fparseln(f, &len, &lineno, NULL, 0)) == NULL)
-			if (feof(f)) {
+			if (feof(f) || ferror(f)) {
 				failed = 1;
 				break;
 			}