This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: localtime_r segfaults, localtime doesn't... same values passed to each function...
- From: Christopher Faylor <cgf-no-personal-reply-please at cygwin dot com>
- To: cygwin at cygwin dot com
- Date: Sun, 10 Jul 2005 18:38:00 -0400
- Subject: Re: localtime_r segfaults, localtime doesn't... same values passed to each function...
- References: <20050710210612.40137.qmail@web88010.mail.re2.yahoo.com>
- Reply-to: cygwin at cygwin dot com
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/