Skip to content

Commit 26bb38e

Browse files
committed
- fix possible NULL deref
1 parent eda798f commit 26bb38e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

TSRM/tsrm_virtual_cwd.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1874,6 +1874,9 @@ CWD_API char *tsrm_realpath(const char *path, char *real_path TSRMLS_DC) /* {{{
18741874
/* realpath("") returns CWD */
18751875
if (!*path) {
18761876
new_state.cwd = (char*)malloc(1);
1877+
if (new_state.cwd == NULL) {
1878+
return NULL;
1879+
}
18771880
new_state.cwd[0] = '\0';
18781881
new_state.cwd_length = 0;
18791882
if (VCWD_GETCWD(cwd, MAXPATHLEN)) {
@@ -1885,6 +1888,9 @@ CWD_API char *tsrm_realpath(const char *path, char *real_path TSRMLS_DC) /* {{{
18851888
new_state.cwd_length = strlen(cwd);
18861889
} else {
18871890
new_state.cwd = (char*)malloc(1);
1891+
if (new_state.cwd == NULL) {
1892+
return NULL;
1893+
}
18881894
new_state.cwd[0] = '\0';
18891895
new_state.cwd_length = 0;
18901896
}

0 commit comments

Comments
 (0)