changeset 3648:3e7493e76dc7

[xemacs-hg @ 2006-11-01 20:25:48 by adrian] fix for ffap crash on Windows (was: [Bug: 21.5-b27] [CRASH] (file-name-directory "1:")) -------------------- ChangeLog entries follow: -------------------- src/ChangeLog addition: 2006-11-01 Adrian Aichner <adrian@xemacs.org> * sysdep.c (wcslen): Check for NULL pointer. * sysdep.c (strlwr): Ditto. * nt.c (mswindows_getdcwd): Ditto (actual cause of reported crash). * intl-win32.c (wcscmp): Ditto. * intl-win32.c (wcslen): Ditto. * intl-win32.c (wcsncpy): Ditto. * intl-win32.c (wcscpy): Ditto. * intl-win32.c (wcsdup): Ditto. * fileio.c (Ffile_name_directory): Return Qnil when mswindows_getdcwd returns NULL working directory.
author adrian
date Wed, 01 Nov 2006 20:25:50 +0000
parents 510e0d6cee7e
children 60b01bffb67f
files src/ChangeLog src/fileio.c src/intl-win32.c src/nt.c src/sysdep.c
diffstat 5 files changed, 36 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Tue Oct 31 22:51:31 2006 +0000
+++ b/src/ChangeLog	Wed Nov 01 20:25:50 2006 +0000
@@ -1,3 +1,17 @@
+2006-11-01  Adrian Aichner  <adrian@xemacs.org>
+
+	* sysdep.c (wcslen): Check for NULL pointer.
+	* sysdep.c (strlwr): Ditto.
+	* nt.c (mswindows_getdcwd): Ditto (actual cause of reported
+	crash).
+	* intl-win32.c (wcscmp): Ditto.
+	* intl-win32.c (wcslen): Ditto.
+	* intl-win32.c (wcsncpy): Ditto.
+	* intl-win32.c (wcscpy): Ditto.
+	* intl-win32.c (wcsdup): Ditto.
+	* fileio.c (Ffile_name_directory): Return Qnil when
+	mswindows_getdcwd returns NULL working directory.
+
 2006-10-30  Malcolm Purvis  <malcolmp@xemacs.org>
 
 	* device-x.c (x_init_device):  Look in more directories when
@@ -42828,7 +42842,7 @@
 	angle brackets.
 	Use RTLD_GLOBAL as an open flag if it exists.
 
-1998-03-09  Martin Buchholz  <Martin Buchholz <martin@xemacs.org>>
+1998-03-09  Martin Buchholz <martin@xemacs.org>
 
 	* eldap.c (Fldap_search_internal): call garbage_collect_1 instead
 	of Fgarbage_collect.  The two are identical except the latter
@@ -42995,7 +43009,7 @@
 
 	* editfns.c (Ftemp_directory): Use build_ext_string.
 
-1998-03-02  Martin Buchholz  <Martin Buchholz <martin@xemacs.org>>
+1998-03-02  Martin Buchholz <martin@xemacs.org>
 
 	* symsinit.h: add prototype for syms_of_dlopen
 
@@ -45520,7 +45534,7 @@
 	* events.c (Fevent_modeline_position): Return nil if event is not
 	over modeline, as the docstring says.
 
-1997-11-05  Martin Buchholz  <Martin Buchholz <martin@xemacs.org>>
+1997-11-05  Martin Buchholz <martin@xemacs.org>
 
 	* s/aix3-1.h: Remove ^L character wich confuses AIX make.
 
--- a/src/fileio.c	Tue Oct 31 22:51:31 2006 +0000
+++ b/src/fileio.c	Wed Nov 01 20:25:50 2006 +0000
@@ -397,12 +397,21 @@
 
       if (wd)
 	{
+	  int size;
 	  qxestrcat (res, wd);
-	  if (!IS_DIRECTORY_SEP (res[qxestrlen (res) - 1]))
-	    qxestrcat (res, (Ibyte *) "/");
+	  size = qxestrlen (res);
+	  if (!IS_DIRECTORY_SEP (res[size - 1]))
+	    {
+	      res[size] = DIRECTORY_SEP;
+	      res[size + 1] = '\0';
+	    }
 	  beg = res;
 	  p = beg + qxestrlen (beg);
 	}
+      else
+	{
+	  return Qnil;
+	}
       if (wd)
 	xfree (wd, Ibyte *);
     }
--- a/src/intl-win32.c	Tue Oct 31 22:51:31 2006 +0000
+++ b/src/intl-win32.c	Wed Nov 01 20:25:50 2006 +0000
@@ -1569,6 +1569,7 @@
 int
 wcscmp (const wchar_t *s1, const wchar_t *s2)
 {
+  if (s1 == NULL || s2 == NULL) return NULL;
   while (*s1 != '\0' && *s1 == *s2)
     {
       s1++;
@@ -1585,6 +1586,7 @@
 size_t
 wcslen (const wchar_t *str)
 {
+  if (str == NULL) return NULL;
   const wchar_t *start = str;
 
   while (*str)
@@ -1598,6 +1600,7 @@
 wchar_t *
 wcsncpy (wchar_t *dst0, const wchar_t *src0, size_t count)
 {
+  if (dst0 == NULL || src0 == NULL) return NULL;
   wchar_t *dscan;
   const wchar_t *sscan;
 
@@ -1618,6 +1621,7 @@
 wchar_t *
 wcscpy (wchar_t *dst0, const wchar_t *src0)
 {
+  if (dst0 == NULL || src0 == NULL) return NULL;
   wchar_t *s = dst0;
 
   while ((*dst0++ = *src0++))
@@ -1629,6 +1633,7 @@
 wchar_t *
 wcsdup (const wchar_t *str)
 {
+  if (str == NULL) return NULL;
   int len = wcslen (str) + 1;
   wchar_t *val = xnew_array (wchar_t, len);
 
--- a/src/nt.c	Tue Oct 31 22:51:31 2006 +0000
+++ b/src/nt.c	Wed Nov 01 20:25:50 2006 +0000
@@ -1819,6 +1819,7 @@
     cwdext = (Extbyte *) _wgetdcwd (drivelet, NULL, 0);
   else
     cwdext = _getdcwd (drivelet, NULL, 0);
+  if (cwdext == NULL) return NULL;
   TSTR_TO_C_STRING_MALLOC (cwdext, cwd);
   xfree (cwdext, Extbyte *);
   return cwd;
--- a/src/sysdep.c	Tue Oct 31 22:51:31 2006 +0000
+++ b/src/sysdep.c	Wed Nov 01 20:25:50 2006 +0000
@@ -3491,6 +3491,7 @@
 size_t
 wcslen (const wchar_t *s)
 {
+  if (s == NULL) return NULL;
   const wchar_t *p = s;
 
   while (*p++)
@@ -3508,6 +3509,7 @@
 char *
 strlwr (char *s)
 {
+  if (s == NULL) return NULL;
   REGISTER char *c;
 
   for (c = s; *c; c++)