Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: curses null dereference risk



If zca is NULL we don't want to try dereferencing it.

Index: Src/Modules/curses.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/curses.c,v
retrieving revision 1.45
diff -u -r1.45 curses.c
--- Src/Modules/curses.c	13 Mar 2008 11:11:04 -0000	1.45
+++ Src/Modules/curses.c	4 Sep 2008 20:08:07 -0000
@@ -948,14 +948,17 @@
 	    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;
+		}
 	    }
 	}
     }



Messages sorted by: Reverse Date, Date, Thread, Author