Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , 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 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 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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/