Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Aug 2010 16:26:09 +0000 (UTC)
From:      Fabien Thomas <fabient@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r210816 - stable/8/lib/libpmc
Message-ID:  <201008031626.o73GQ99B097641@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: fabient
Date: Tue Aug  3 16:26:09 2010
New Revision: 210816
URL: http://svn.freebsd.org/changeset/base/210816

Log:
  MFC r208860:
  
  Fix memory leak on error.
  
  Found with:	Coverity Prevent(tm)

Modified:
  stable/8/lib/libpmc/pmclog.c
Directory Properties:
  stable/8/lib/libpmc/   (props changed)

Modified: stable/8/lib/libpmc/pmclog.c
==============================================================================
--- stable/8/lib/libpmc/pmclog.c	Tue Aug  3 16:24:52 2010	(r210815)
+++ stable/8/lib/libpmc/pmclog.c	Tue Aug  3 16:26:09 2010	(r210816)
@@ -549,8 +549,10 @@ pmclog_open(int fd)
 
 	/* allocate space for a work area */
 	if (ps->ps_fd != PMCLOG_FD_NONE) {
-		if ((ps->ps_buffer = malloc(PMCLOG_BUFFER_SIZE)) == NULL)
+		if ((ps->ps_buffer = malloc(PMCLOG_BUFFER_SIZE)) == NULL) {
+			free(ps);
 			return NULL;
+		}
 	}
 
 	return ps;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201008031626.o73GQ99B097641>