Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 5 Jun 2010 23:00:02 +0000 (UTC)
From:      Fabien Thomas <fabient@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r208860 - head/lib/libpmc
Message-ID:  <201006052300.o55N02BX063539@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: fabient
Date: Sat Jun  5 23:00:02 2010
New Revision: 208860
URL: http://svn.freebsd.org/changeset/base/208860

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

Modified:
  head/lib/libpmc/pmclog.c

Modified: head/lib/libpmc/pmclog.c
==============================================================================
--- head/lib/libpmc/pmclog.c	Sat Jun  5 22:59:37 2010	(r208859)
+++ head/lib/libpmc/pmclog.c	Sat Jun  5 23:00:02 2010	(r208860)
@@ -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?201006052300.o55N02BX063539>