APPROVE COMMIT 21.4 RECOMMEND 21.5
Note that the patch presumably won't apply to 21.5, as the
implementation has been Mule-ized there.
>>>> "Nick" == Nick V Pakoulin
<npak(a)ispras.ru> writes:
Nick> `decode-time' also suffers from windows implementation of
Nick> locatime. The patch fixes both crashes.
The check for NULL is also correct for glibc, although I don't think
it can be triggered.
The current implementation of lisp_time doesn't look 64-bit clean, but
I'm no expert.
Index: src/ChangeLog
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/ChangeLog,v
retrieving revision 1.290.2.20.2.2
diff -u -U0 -r1.290.2.20.2.2 ChangeLog
--- src/ChangeLog 9 May 2002 19:37:37 -0000 1.290.2.20.2.2
+++ src/ChangeLog 13 May 2002 15:18:36 -0000
@@ -0,0 +1,20 @@
+2002-05-14 Stephen J. Turnbull <stephen(a)xemacs.org>
+
+ * editfns.c (Fdecode_time):
+ (Fformat_time_string):
+ Check for invalid time. Thanks to Nick Pakoulin <npak(a)ispras.ru>.
+
Index: src/editfns.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/editfns.c,v
retrieving revision 1.27.2.3
diff -u -r1.27.2.3 editfns.c
--- src/editfns.c 17 Dec 2001 05:49:24 -0000 1.27.2.3
+++ src/editfns.c 13 May 2002 15:18:46 -0000
@@ -1107,10 +1107,11 @@
{
time_t value;
size_t size;
+ struct tm * tm;
CHECK_STRING (format_string);
- if (! lisp_to_time (time_, &value))
+ if (! lisp_to_time (time_, &value) || ! (tm = localtime (&value)))
error ("Invalid time specification");
/* This is probably enough. */
@@ -1122,7 +1123,7 @@
*buf = 1;
if (emacs_strftime (buf, size,
(const char *) XSTRING_DATA (format_string),
- localtime (&value))
+ tm)
|| !*buf)
return build_ext_string (buf, Qbinary);
/* If buffer was too small, make it bigger. */
@@ -1151,10 +1152,10 @@
struct tm *decoded_time;
Lisp_Object list_args[9];
- if (! lisp_to_time (specified_time, &time_spec))
+ if (! lisp_to_time (specified_time, &time_spec)
+ || ! (decoded_time = localtime (&time_spec)))
error ("Invalid time specification");
- decoded_time = localtime (&time_spec);
list_args[0] = make_int (decoded_time->tm_sec);
list_args[1] = make_int (decoded_time->tm_min);
list_args[2] = make_int (decoded_time->tm_hour);
--
Institute of Policy and Planning Sciences
http://turnbull.sk.tsukuba.ac.jp
University of Tsukuba Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
My nostalgia for Icon makes me forget about any of the bad things. I don't
have much nostalgia for Perl, so its faults I remember. Scott Gilbert c.l.py