From owner-freebsd-bugs@FreeBSD.ORG Sun Oct 9 15:00:23 2011 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F05131065672 for ; Sun, 9 Oct 2011 15:00:22 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id C0CCA8FC0A for ; Sun, 9 Oct 2011 15:00:22 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id p99F0MmG097968 for ; Sun, 9 Oct 2011 15:00:22 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id p99F0MPA097957; Sun, 9 Oct 2011 15:00:22 GMT (envelope-from gnats) Resent-Date: Sun, 9 Oct 2011 15:00:22 GMT Resent-Message-Id: <201110091500.p99F0MPA097957@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Fabian Keil Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 412C11065670 for ; Sun, 9 Oct 2011 14:50:45 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id 30F4B8FC08 for ; Sun, 9 Oct 2011 14:50:45 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p99EoiYA033444 for ; Sun, 9 Oct 2011 14:50:44 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id p99EoiHW033443; Sun, 9 Oct 2011 14:50:44 GMT (envelope-from nobody) Message-Id: <201110091450.p99EoiHW033443@red.freebsd.org> Date: Sun, 9 Oct 2011 14:50:44 GMT From: Fabian Keil To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: misc/161425: Memory leak in localtime.c's tzload() X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Oct 2011 15:00:23 -0000 >Number: 161425 >Category: misc >Synopsis: Memory leak in localtime.c's tzload() >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Oct 09 15:00:22 UTC 2011 >Closed-Date: >Last-Modified: >Originator: Fabian Keil >Release: HEAD >Organization: >Environment: >Description: r225677 seems to have introduced a memory leak: ==6439== 1,025 bytes in 1 blocks are definitely lost in loss record 95 of 132 ==6439== at 0x105E47B: malloc (vg_replace_malloc.c:236) ==6439== by 0x1BCEA42: ??? (localtime.c:414) ==6439== by 0x1BCF41A: ??? (localtime.c:1253) ==6439== by 0x1BCF7F3: localtime_r (localtime.c:1482) ==6439== by 0x41F9F7: get_log_timestamp (errlog.c:454) ==6439== by 0x41FF90: log_error (errlog.c:690) ==6439== by 0x41F646: show_version (errlog.c:199) ==6439== by 0x42D204: main (jcc.c:3036) >How-To-Repeat: Use valgrind with an application that uses (for example) localtime_r(). >Fix: The attached patch seems to fix it for me. Patch attached with submission follows: >From 2e481a94e78d21c75f43706f637660fe0a7c3ab7 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Sat, 8 Oct 2011 20:28:16 +0200 Subject: [PATCH] Fix a memory leak in tzload() --- contrib/tzcode/stdtime/localtime.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/contrib/tzcode/stdtime/localtime.c b/contrib/tzcode/stdtime/localtime.c index d9544a9..a59bb1d 100644 --- a/contrib/tzcode/stdtime/localtime.c +++ b/contrib/tzcode/stdtime/localtime.c @@ -445,8 +445,8 @@ register const int doextend; free(fullname); return -1; } + free(fullname); if ((_fstat(fid, &stab) < 0) || !S_ISREG(stab.st_mode)) { - free(fullname); _close(fid); return -1; } -- 1.7.6 >Release-Note: >Audit-Trail: >Unformatted: