@@ -270,6 +270,11 @@ PS_OPEN_FUNC(memcached)
270
270
PS_CLOSE_FUNC (memcached )
271
271
{
272
272
memcached_sess * memc_sess = PS_GET_MOD_DATA ();
273
+
274
+ if (!memc_sess ) {
275
+ php_error_docref (NULL TSRMLS_CC , E_WARNING , "Session is not allocated, check session.save_path value" );
276
+ return FAILURE ;
277
+ }
273
278
274
279
if (MEMC_G (sess_locking_enabled )) {
275
280
php_memc_sess_unlock (memc_sess -> memc_sess TSRMLS_CC );
@@ -300,6 +305,11 @@ PS_READ_FUNC(memcached)
300
305
memcached_sess * memc_sess = PS_GET_MOD_DATA ();
301
306
size_t key_length ;
302
307
308
+ if (!memc_sess ) {
309
+ php_error_docref (NULL TSRMLS_CC , E_WARNING , "Session is not allocated, check session.save_path value" );
310
+ return FAILURE ;
311
+ }
312
+
303
313
key_length = strlen (MEMC_G (sess_prefix )) + key_len + 5 ; // prefix + "lock."
304
314
if (!key_length || key_length >= MEMCACHED_MAX_KEY ) {
305
315
php_error_docref (NULL TSRMLS_CC , E_WARNING , "The session id is too long or contains illegal characters" );
@@ -334,6 +344,11 @@ PS_WRITE_FUNC(memcached)
334
344
memcached_return status ;
335
345
memcached_sess * memc_sess = PS_GET_MOD_DATA ();
336
346
size_t key_length ;
347
+
348
+ if (!memc_sess ) {
349
+ php_error_docref (NULL TSRMLS_CC , E_WARNING , "Session is not allocated, check session.save_path value" );
350
+ return FAILURE ;
351
+ }
337
352
338
353
key_length = strlen (MEMC_G (sess_prefix )) + key_len + 5 ; // prefix + "lock."
339
354
if (!key_length || key_length >= MEMCACHED_MAX_KEY ) {
@@ -367,6 +382,11 @@ PS_DESTROY_FUNC(memcached)
367
382
{
368
383
memcached_sess * memc_sess = PS_GET_MOD_DATA ();
369
384
385
+ if (!memc_sess ) {
386
+ php_error_docref (NULL TSRMLS_CC , E_WARNING , "Session is not allocated, check session.save_path value" );
387
+ return FAILURE ;
388
+ }
389
+
370
390
memcached_delete (memc_sess -> memc_sess , key , strlen (key ), 0 );
371
391
if (MEMC_G (sess_locking_enabled )) {
372
392
php_memc_sess_unlock (memc_sess -> memc_sess TSRMLS_CC );
0 commit comments