Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1f41f84

Browse files
committed
Instead of calling mktime(), which has all sorts of unwanted side
effects, simply zero out the struct tm buffer before using it; this should take care of the BSD folks' concern just as well.
1 parent d30dc0a commit 1f41f84

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

Modules/timemodule.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,8 @@ time_strftime(self, args)
304304
char *outbuf = 0;
305305
int i;
306306

307+
memset((ANY *) &buf, '\0', sizeof(buf));
308+
307309
if (!PyArg_ParseTuple(args, "s(iiiiiiiii)",
308310
&fmt,
309311
&(buf.tm_year),
@@ -321,12 +323,6 @@ time_strftime(self, args)
321323
buf.tm_mon--;
322324
buf.tm_wday = (buf.tm_wday + 1) % 7;
323325
buf.tm_yday--;
324-
#ifdef HAVE_MKTIME
325-
/* This call is only there to adjust the numbers to be within
326-
bounds. When we don't have mktime(), we say the caller is
327-
responsible for that... */
328-
(void) mktime(&buf);
329-
#endif
330326
/* I hate these functions that presume you know how big the output
331327
* will be ahead of time...
332328
*/

0 commit comments

Comments
 (0)