From c67a873ae6b29bd63d3f7dd8de578eb301d1d6fb Mon Sep 17 00:00:00 2001 From: Nelson Ferreira Date: Wed, 18 Jan 2012 13:06:23 -0500 Subject: [PATCH] Coverity: UNINIT: CID 397 * src/buffer.c (directory_is_current_directory): Handle the case of failed transcoding by attempting to use the non-transcoded version. There is a high chance it is proper. Worst case it will also fail, like the bad conversion would have prompted. Signed-off-by: Nelson Ferreira --- src/buffer.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/buffer.c b/src/buffer.c index 734cb7b..5a8fd89 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -3033,14 +3033,23 @@ moves over the text. /* Is PWD another name for `.' ? */ static int directory_is_current_directory(Extbyte * pwd) { - Bufbyte *pwd_internal; + Bufbyte *pwd_internal = NULL; Bytecount pwd_internal_len; struct stat dotstat, pwdstat; TO_INTERNAL_FORMAT(DATA, (pwd, strlen((char *)pwd) + 1), ALLOCA, (pwd_internal, pwd_internal_len), Qfile_name); - + if( pwd_internal == NULL ) { + /* Failure for failure, lets try using the external + format anyway.. + */ + pwd_internal=pwd; + + } + if( pwd_internal == NULL ) { + return 0; + } return (IS_DIRECTORY_SEP(*pwd_internal) && sxemacs_stat((char *)pwd_internal, &pwdstat) == 0 && sxemacs_stat(".", &dotstat) == 0 @@ -3053,7 +3062,7 @@ void init_initial_directory(void) { /* This function can GC */ - Extbyte *pwd; + Extbyte *pwd = NULL; initial_directory[0] = 0; -- 2.25.1