# HG changeset patch # User adrian # Date 1162412750 0 # Node ID 3e7493e76dc778cc11d8679c987aa9d28fe36a68 # Parent 510e0d6cee7ea55179ca00e84c5445524387f729 [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 * 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. diff -r 510e0d6cee7e -r 3e7493e76dc7 src/ChangeLog --- 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 + + * 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 * 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 > +1998-03-09 Martin Buchholz * 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 > +1998-03-02 Martin Buchholz * 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 > +1997-11-05 Martin Buchholz * s/aix3-1.h: Remove ^L character wich confuses AIX make. diff -r 510e0d6cee7e -r 3e7493e76dc7 src/fileio.c --- 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 *); } diff -r 510e0d6cee7e -r 3e7493e76dc7 src/intl-win32.c --- 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); diff -r 510e0d6cee7e -r 3e7493e76dc7 src/nt.c --- 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; diff -r 510e0d6cee7e -r 3e7493e76dc7 src/sysdep.c --- 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++)