From owner-freebsd-bugs Wed Jun 20 14:30: 7 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 8730B37B401 for ; Wed, 20 Jun 2001 14:30:02 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.3/8.11.3) id f5KLU2i65743; Wed, 20 Jun 2001 14:30:02 -0700 (PDT) (envelope-from gnats) Date: Wed, 20 Jun 2001 14:30:02 -0700 (PDT) Message-Id: <200106202130.f5KLU2i65743@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Mark Valentine Subject: Re: gnu/28189: [PATCH] fix for detecting empty CVS commit log message Reply-To: Mark Valentine Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org The following reply was made to PR gnu/28189; it has been noted by GNATS. From: Mark Valentine To: FreeBSD-gnats-submit@freebsd.org Cc: Subject: Re: gnu/28189: [PATCH] fix for detecting empty CVS commit log message Date: Wed, 20 Jun 2001 22:22:26 +0100 (BST) Here's a new patch incorporating the official fix which was checked into the cvs cvs(!) tree; it also fixes a related memory leak. ChangeLog entry as follows: 2001-06-20 Derek Price * logmsg.c (do_editor): Abort in the case that the file has only comment lines. (Original patch from Mark Valentine .) * logmsg.c (do_editor): Fix rare memory leak. Index: contrib/cvs/src/logmsg.c =================================================================== RCS file: /usr/cvs/src/contrib/cvs/src/logmsg.c,v retrieving revision 1.7 diff -u -r1.7 logmsg.c --- contrib/cvs/src/logmsg.c 2000/10/02 06:43:56 1.7 +++ contrib/cvs/src/logmsg.c 2001/06/20 17:08:31 @@ -307,7 +307,7 @@ /* On NT, we might read less than st_size bytes, but we won't read more. So this works. */ *messagep = (char *) xmalloc (post_stbuf.st_size + 1); - *messagep[0] = '\0'; + (*messagep)[0] = '\0'; } line = NULL; @@ -340,8 +340,14 @@ if (pre_stbuf.st_mtime == post_stbuf.st_mtime || *messagep == NULL || + (*messagep)[0] == '\0' || strcmp (*messagep, "\n") == 0) { + if (*messagep) + { + free (*messagep); + *messagep = NULL; + } for (;;) { (void) printf ("\nLog message unchanged or not specified\n"); -- Mark Valentine, Thuvia Labs "Tigers will do ANYTHING for a tuna fish sandwich." Mark Valentine uses "We're kind of stupid that way." *munch* *munch* and endorses FreeBSD -- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message