zsh-workers
 help / color / mirror / code / Atom feed
From: Clint Adams <clint@zsh.org>
To: zsh-workers@sunsite.dk
Cc: eclark@coverity.com
Subject: PATCH: curses null dereference risk
Date: Thu, 4 Sep 2008 20:09:41 +0000	[thread overview]
Message-ID: <20080904200941.GA30454@scru.org> (raw)

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;
+		}
 	    }
 	}
     }


                 reply	other threads:[~2008-09-04 23:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080904200941.GA30454@scru.org \
    --to=clint@zsh.org \
    --cc=eclark@coverity.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).