summary refs log tree commit diff
diff options
context:
space:
mode:
authorClint Adams <clint@users.sourceforge.net>2008-09-05 00:24:27 +0000
committerClint Adams <clint@users.sourceforge.net>2008-09-05 00:24:27 +0000
commit13f60efbd7d8572e2850dae9c0adbcc137be3e92 (patch)
tree9205371c61e0afc12aeda999aa4f88c513a68d84
parent29680850a0f13c759e0530f836e3099ebfeab18c (diff)
downloadzsh-13f60efbd7d8572e2850dae9c0adbcc137be3e92.tar.gz
zsh-13f60efbd7d8572e2850dae9c0adbcc137be3e92.tar.xz
zsh-13f60efbd7d8572e2850dae9c0adbcc137be3e92.zip
25611, 25613: protect against two possible NULL dereferences.
-rw-r--r--ChangeLog3
-rw-r--r--Src/Modules/curses.c40
2 files changed, 25 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index 7e77e3231..20c7714d5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2008-09-04  Clint Adams  <clint@zsh.org>
 
+	* 25611, 25613: Src/Modules/curses.c: protect against two possible
+	NULL dereferences.
+
 	* 25612: Src/Zle/compmatch.c: remove dead code.
 
 	* 25610: Src/hist.c: remove dead code.
diff --git a/Src/Modules/curses.c b/Src/Modules/curses.c
index df8a9cdc6..fe03cd268 100644
--- a/Src/Modules/curses.c
+++ b/Src/Modules/curses.c
@@ -874,16 +874,17 @@ zccmd_attr(const char *nam, char **args)
 	    if ((zca = zcurses_attrget(w->win, ptr)) == NULL) {
 		zwarnnam(nam, "attribute `%s' not known", ptr);
 		ret = 1;
-	    }
-	    switch(onoff) {
-		case ZCURSES_ATTRON:
-		    if (wattron(w->win, zca->number) == ERR)
-			ret = 1;
-		    break;
-		case ZCURSES_ATTROFF:
-		    if (wattroff(w->win, zca->number) == ERR)
-			ret = 1;
-		    break;
+	    } else {
+		switch(onoff) {
+		    case ZCURSES_ATTRON:
+			if (wattron(w->win, zca->number) == ERR)
+			    ret = 1;
+			break;
+		    case ZCURSES_ATTROFF:
+			if (wattroff(w->win, zca->number) == ERR)
+			    ret = 1;
+			break;
+		}
 	    }
 	}
     }
@@ -948,14 +949,17 @@ zccmd_bg(const char *nam, char **args)
 	    if ((zca = zcurses_attrget(w->win, ptr)) == NULL) {
 		zwarnnam(nam, "attribute `%s' not known", ptr);
 		ret = 1;
-	    }
-	    switch(onoff) {
-		case ZCURSES_ATTRON:
-		    ch |= zca->number;
-		    break;
-		case ZCURSES_ATTROFF:
-		    ch &= ~zca->number;
-		    break;
+	    } else {
+		switch(onoff) {
+		    case ZCURSES_ATTRON:
+			if (wattron(w->win, zca->number) == ERR)
+			    ret = 1;
+			break;
+		    case ZCURSES_ATTROFF:
+			if (wattroff(w->win, zca->number) == ERR)
+			    ret = 1;
+			break;
+		}
 	    }
 	}
     }