Skip to content

Commit

Permalink
- fix possible NULL deref
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrejoye committed Jan 10, 2011
1 parent eda798f commit 26bb38e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions TSRM/tsrm_virtual_cwd.c
Expand Up @@ -1874,6 +1874,9 @@ CWD_API char *tsrm_realpath(const char *path, char *real_path TSRMLS_DC) /* {{{
/* realpath("") returns CWD */
if (!*path) {
new_state.cwd = (char*)malloc(1);
if (new_state.cwd == NULL) {
return NULL;
}
new_state.cwd[0] = '\0';
new_state.cwd_length = 0;
if (VCWD_GETCWD(cwd, MAXPATHLEN)) {
Expand All @@ -1885,6 +1888,9 @@ CWD_API char *tsrm_realpath(const char *path, char *real_path TSRMLS_DC) /* {{{
new_state.cwd_length = strlen(cwd);
} else {
new_state.cwd = (char*)malloc(1);
if (new_state.cwd == NULL) {
return NULL;
}
new_state.cwd[0] = '\0';
new_state.cwd_length = 0;
}
Expand Down

0 comments on commit 26bb38e

Please sign in to comment.