Navigation Menu

Skip to content

Commit

Permalink
fix segfault in php_add_session_var()
Browse files Browse the repository at this point in the history
  • Loading branch information
tony2001 committed Feb 15, 2007
1 parent 25f51c3 commit 61261dc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
17 changes: 10 additions & 7 deletions ext/session/session.c
Expand Up @@ -271,8 +271,12 @@ void php_add_session_var(char *name, size_t namelen TSRMLS_DC)
{
zval **sym_track = NULL;

zend_hash_find(Z_ARRVAL_P(PS(http_session_vars)), name, namelen + 1,
(void *) &sym_track);
IF_SESSION_VARS() {
zend_hash_find(Z_ARRVAL_P(PS(http_session_vars)), name, namelen + 1,
(void *) &sym_track);
} else {
return;
}

/*
* Set up a proper reference between $_SESSION["x"] and $x.
Expand All @@ -281,11 +285,10 @@ void php_add_session_var(char *name, size_t namelen TSRMLS_DC)
if (PG(register_globals)) {
zval **sym_global = NULL;

zend_hash_find(&EG(symbol_table), name, namelen + 1,
(void *) &sym_global);

if ((Z_TYPE_PP(sym_global) == IS_ARRAY && Z_ARRVAL_PP(sym_global) == &EG(symbol_table)) || *sym_global == PS(http_session_vars)) {
return;
if (zend_hash_find(&EG(symbol_table), name, namelen + 1, (void *) &sym_global) == SUCCESS) {
if ((Z_TYPE_PP(sym_global) == IS_ARRAY && Z_ARRVAL_PP(sym_global) == &EG(symbol_table)) || *sym_global == PS(http_session_vars)) {
return;
}
}

if (sym_global == NULL && sym_track == NULL) {
Expand Down
1 change: 1 addition & 0 deletions ext/session/tests/002.phpt
Expand Up @@ -7,6 +7,7 @@ session_unset() without a initialized session
error_reporting(E_ALL);
session_unset();
print "ok\n";
?>
--GET--
--POST--
--EXPECT--
Expand Down

0 comments on commit 61261dc

Please sign in to comment.