NetBSD Problem Report #46818

From www@NetBSD.org  Mon Aug 20 11:40:07 2012
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	by www.NetBSD.org (Postfix) with ESMTP id 0697563C3D5
	for <gnats-bugs@gnats.NetBSD.org>; Mon, 20 Aug 2012 11:40:07 +0000 (UTC)
Message-Id: <20120820114006.75F9763B882@www.NetBSD.org>
Date: Mon, 20 Aug 2012 11:40:06 +0000 (UTC)
From: henning.petersen@t-online.de
Reply-To: henning.petersen@t-online.de
To: gnats-bugs@NetBSD.org
Subject: Replace malloc with calloc in fts.c
X-Send-Pr-Version: www-1.0

>Number:         46818
>Category:       lib
>Synopsis:       Replace malloc with calloc in fts.c
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    pgoyette
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Aug 20 11:45:00 +0000 2012
>Closed-Date:    Tue May 31 07:51:00 +0000 2016
>Last-Modified:  Tue May 31 07:51:00 +0000 2016
>Originator:     Henning Petersen
>Release:        NetBSD-current
>Organization:
>Environment:
>Description:
Replace malloc and memset with calloc.
>How-To-Repeat:

>Fix:
diff -u -p -r1.44 fts.c
--- lib/libc/gen/fts.c	14 Mar 2012 00:25:19 -0000	1.44
+++ lib/libc/gen/fts.c	2 Aug 2012 15:45:07 -0000
@@ -133,9 +133,8 @@ fts_open(char * const *argv, int options
 	}

 	/* Allocate/initialize the stream */
-	if ((sp = malloc((unsigned int)sizeof(FTS))) == NULL)
+	if ((sp = calloc(1, sizeof(FTS))) == NULL)
 		return (NULL);
-	memset(sp, 0, sizeof(FTS));
 	sp->fts_compar = compar;
 	sp->fts_options = options;

>Release-Note:

>Audit-Trail:
From: "Paul Goyette" <pgoyette@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/46818 CVS commit: src/lib/libc/gen
Date: Tue, 31 May 2016 07:49:10 +0000

 Module Name:	src
 Committed By:	pgoyette
 Date:		Tue May 31 07:49:10 UTC 2016

 Modified Files:
 	src/lib/libc/gen: fts.c

 Log Message:
 Use calloc(1, ...) instead of malloc(...) followed immediately by memset()

 Addresses PR lib/46818


 To generate a diff of this commit:
 cvs rdiff -u -r1.48 -r1.49 src/lib/libc/gen/fts.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

Responsible-Changed-From-To: lib-bug-people->pgoyette
Responsible-Changed-By: pgoyette@NetBSD.org
Responsible-Changed-When: Tue, 31 May 2016 07:51:00 +0000
Responsible-Changed-Why:
I'll handle it.


State-Changed-From-To: open->closed
State-Changed-By: pgoyette@NetBSD.org
State-Changed-When: Tue, 31 May 2016 07:51:00 +0000
State-Changed-Why:
Reqwuested fix committed.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.