delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/07/10/18:38:13

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Sun, 10 Jul 2005 18:38:00 -0400
From: Christopher Faylor <cgf-no-personal-reply-please AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: localtime_r segfaults, localtime doesn't... same values passed to each function...
Message-ID: <20050710223800.GA29167@trixie.casa.cgf.cx>
Reply-To: cygwin AT cygwin DOT com
References: <20050710210612 DOT 40137 DOT qmail AT web88010 DOT mail DOT re2 DOT yahoo DOT com>
Mime-Version: 1.0
In-Reply-To: <20050710210612.40137.qmail@web88010.mail.re2.yahoo.com>
User-Agent: Mutt/1.5.8i

On Sun, Jul 10, 2005 at 05:06:12PM -0400, Brian Bisaillon wrote:
>This works...
> 
>struct tm *sci_localtime (time_t timep) {
>    struct tm *result;
>    if ((result = localtime(&timep)) == NULL) {
>    int errsv = errno;
>        fprintf (stderr, "\nError Code %i: %s at line
>%i of %s function in %s \
>            \n", strerror (errsv), 2,
>"sci_localtime_r", "sci_time.c");
>        exit (EXIT_FAILURE);
>    } else {
>        return (result);
>    }
>}
> 
>This doesn't...
> 
>struct tm *sci_localtime_r (time_t timep) {
>    struct tm *result;
>    if ((localtime_r(&timep, result)) == NULL) {
                              ^^^^^^

You're passing an uninitialized pointer as the second argument to
localtime_r.  This is supposed to be the address of a user-defined
struct.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019