This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: localtime_r segfaults, localtime doesn't... same values passed to each function...


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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]