zsh-workers
 help / color / mirror / code / Atom feed
* 2 valgrind warnings and their fixes
@ 2004-10-17 20:42 Wayne Davison
  2004-10-18  0:39 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Wayne Davison @ 2004-10-17 20:42 UTC (permalink / raw)
  To: zsh-workers

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..


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: 2 valgrind warnings and their fixes
  2004-10-17 20:42 2 valgrind warnings and their fixes Wayne Davison
@ 2004-10-18  0:39 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2004-10-18  0:39 UTC (permalink / raw)
  To: zsh-workers

On Sun, 17 Oct 2004, Wayne Davison wrote:

> Any reason why we wouldn't want to make this change?

Not that I can think of.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-10-18  0:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-17 20:42 2 valgrind warnings and their fixes Wayne Davison
2004-10-18  0:39 ` Bart Schaefer

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).