Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3d7be35

Browse files
Consolidate failure path
1 parent 0e92616 commit 3d7be35

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

redis_session.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ PHP_REDIS_API void
108108
redis_pool_free(redis_pool *pool) {
109109

110110
redis_pool_member *rpm, *next;
111+
112+
if (pool == NULL)
113+
return;
114+
111115
rpm = pool->head;
112116
while (rpm) {
113117
next = rpm->next;
@@ -460,9 +464,7 @@ PS_OPEN_FUNC(redis)
460464
"Failed to parse session.save_path (error at offset %d, url was '%s')", i, path);
461465
efree(path);
462466

463-
redis_pool_free(pool);
464-
PS_SET_MOD_DATA(NULL);
465-
return FAILURE;
467+
goto fail;
466468
}
467469

468470
ZVAL_NULL(&context);
@@ -509,10 +511,8 @@ PS_OPEN_FUNC(redis)
509511
if (prefix) zend_string_release(prefix);
510512
if (user) zend_string_release(user);
511513
if (pass) zend_string_release(pass);
512-
redis_pool_free(pool);
513-
PS_SET_MOD_DATA(NULL);
514514

515-
return FAILURE;
515+
goto fail;
516516
}
517517

518518
RedisSock *redis_sock;
@@ -563,7 +563,9 @@ PS_OPEN_FUNC(redis)
563563
return SUCCESS;
564564
}
565565

566+
fail:
566567
redis_pool_free(pool);
568+
PS_SET_MOD_DATA(NULL);
567569
return FAILURE;
568570
}
569571
/* }}} */

0 commit comments

Comments
 (0)