about summary refs log tree commit diff
path: root/Src/Modules
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 /Src/Modules
parent29680850a0f13c759e0530f836e3099ebfeab18c (diff)
downloadzsh-13f60efbd7d8572e2850dae9c0adbcc137be3e92.tar.gz
zsh-13f60efbd7d8572e2850dae9c0adbcc137be3e92.tar.xz
zsh-13f60efbd7d8572e2850dae9c0adbcc137be3e92.zip
25611, 25613: protect against two possible NULL dereferences.
Diffstat (limited to 'Src/Modules')
-rw-r--r--Src/Modules/curses.c40
1 files changed, 22 insertions, 18 deletions
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;
+		}
 	    }
 	}
     }