[COMMITTED] Don't crash in iconv setup when getcwd fails.
Commit Message
When __getcwd fails, __gconv_get_path will call strlen on a null pointer.
This fix at least delays the crash until the cwd is actually needed (if it
ever is). This makes some iconv/ tests work in a circumstance where getcwd
fails.
Thanks,
Roland
2015-02-25 Roland McGrath <roland@hack.frob.com>
* iconv/gconv_conf.c (__gconv_get_path): Don't crash if __getcwd
returns a null pointer.
@@ -468,7 +468,7 @@ __gconv_get_path (void)
":", 1),
default_gconv_path, sizeof (default_gconv_path));
cwd = __getcwd (NULL, 0);
- cwdlen = strlen (cwd);
+ cwdlen = __glibc_unlikely (cwd == NULL) ? 0 : strlen (cwd);
}
assert (default_gconv_path[0] == '/');