From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 659 invoked from network); 17 Oct 2004 20:43:32 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 17 Oct 2004 20:43:32 -0000 Received: (qmail 82094 invoked from network); 17 Oct 2004 20:43:26 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 17 Oct 2004 20:43:26 -0000 Received: (qmail 354 invoked by alias); 17 Oct 2004 20:43:22 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 20496 Received: (qmail 340 invoked from network); 17 Oct 2004 20:43:21 -0000 Received: from unknown (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 17 Oct 2004 20:43:21 -0000 Received: (qmail 81197 invoked from network); 17 Oct 2004 20:42:24 -0000 Received: from dsl3-63-249-88-2.cruzio.com (HELO binome.blorf.net) (63.249.88.2) by a.mx.sunsite.dk with SMTP; 17 Oct 2004 20:42:23 -0000 Received: by binome.blorf.net (Postfix, from userid 1000) id F0CF76C29; Sun, 17 Oct 2004 13:42:21 -0700 (PDT) Date: Sun, 17 Oct 2004 13:42:21 -0700 From: Wayne Davison To: zsh-workers@sunsite.dk Subject: 2 valgrind warnings and their fixes Message-ID: <20041017204221.GB26158@blorf.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.6+20040722i X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=-0.0 required=6.0 tests=BAYES_44 autolearn=no version=2.63 X-Spam-Hits: -0.0 In zleread() (in Zle/zle_main.c), I just added a line that sets the first byte of the newly malloced "line" buffer to '\0'. Without this, typing a space as the first character on the line generates a warning about magicspace()'s call of strchr() accessing uninitialized memory (if space is bound to magic-space, of course). Another warning that occurs quite a bit is this one: Warning: invalid file descriptor -1 in syscall close() Sure, that's not very worrisome, but it is easy to get rid of with a simple change to zclose() that ensures that close() will only get called when fd >= 0: --- Src/utils.c 5 Oct 2004 10:39:43 -0000 1.66 +++ Src/utils.c 17 Oct 2004 20:35:51 -0000 @@ -1117,8 +1117,9 @@ zclose(int fd) coprocin = -1; if (fd == coprocout) coprocout = -1; + return close(fd); } - return close(fd); + return -1; } /* Get a file name relative to $TMPPREFIX which * Any reason why we wouldn't want to make this change? I don't see anyone that is expecting errno to be set in such a case (nor anyone who even checks the return value of zclose()). ..wayne..