summaryrefslogtreecommitdiff
path: root/ext/sysvshm
diff options
context:
space:
mode:
Diffstat (limited to 'ext/sysvshm')
-rw-r--r--ext/sysvshm/sysvshm.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/ext/sysvshm/sysvshm.c b/ext/sysvshm/sysvshm.c
index 520b7b798e..a66d85e4c3 100644
--- a/ext/sysvshm/sysvshm.c
+++ b/ext/sysvshm/sysvshm.c
@@ -251,13 +251,18 @@ PHP_FUNCTION(shm_put_var)
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlz", &shm_id, &shm_key, &arg_var)) {
return;
}
- SHM_FETCH_RESOURCE(shm_list_ptr, shm_id);
/* setup string-variable and serialize */
PHP_VAR_SERIALIZE_INIT(var_hash);
php_var_serialize(&shm_var, &arg_var, &var_hash TSRMLS_CC);
PHP_VAR_SERIALIZE_DESTROY(var_hash);
+ shm_list_ptr = zend_fetch_resource(&shm_id TSRMLS_CC, -1, PHP_SHM_RSRC_NAME, NULL, 1, php_sysvshm.le_shm);
+ if (!shm_list_ptr) {
+ smart_str_free(&shm_var);
+ RETURN_FALSE;
+ }
+
/* insert serialized variable into shared memory */
ret = php_put_shm_data(shm_list_ptr->ptr, shm_key, shm_var.c, shm_var.len);