cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-tracker mailing list Archives

[ curl-Bugs-1468330 ] time_t type-cast problem with VS2005

From: SourceForge.net <noreply_at_sourceforge.net>
Date: Tue, 11 Apr 2006 03:46:25 -0700

Bugs item #1468330, was opened at 2006-04-11 12:13
Message generated for change (Comment added) made by bagder
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=1468330&group_id=976

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: compile or build problem
Group: crash
Status: Open
>Resolution: Fixed
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Daniel Stenberg (bagder)
Summary: time_t type-cast problem with VS2005

Initial Comment:
main.c #line 2987

  tv = curlx_tvnow();
  now = localtime((time_t *)&tv.tv_sec);

Crash in localtime() (Debug-Version), because the
type-cast to time_t-pointer above!

Type of tv.tv_sec : unsigned integer (32-BIT).
Type of time_t is (now) the same as __time64_t !

Maybe compile-time definitione "_USE_32BIT_TIME_T"
should be used ...

----------------------------------------------------------------------

>Comment By: Daniel Stenberg (bagder)
Date: 2006-04-11 12:46

Message:
Logged In: YES
user_id=1110

Thanks!

I suggest and will apply the fix below:

diff -u -r1.356 main.c
--- main.c 9 Apr 2006 22:41:23 -0000 1.356
+++ main.c 11 Apr 2006 10:45:43 -0000
@@ -3078,11 +3078,13 @@
   struct timeval tv;
   struct tm *now;
   char timebuf[20];
+ time_t secs;
 
   (void)handle; /* prevent compiler warning */
 
   tv = curlx_tvnow();
- now = localtime((time_t *)&tv.tv_sec); /* not
multithread safe but we don't care */
+ secs = tv.tv_sec;
+ now = localtime(&secs); /* not multithread safe but we
don't care */
   if(config->tracetime)
     snprintf(timebuf, sizeof(timebuf), "%02d:%02d:%02d.%06d ",
              now->tm_hour, now->tm_min, now->tm_sec,
tv.tv_usec);

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=1468330&group_id=976
Received on 2006-04-11

These mail archives are generated by hypermail.

donate! Page updated November 12, 2010.
web site info

File upload with ASP.NET