Skip to content

Commit 8e173f9

Browse files
committed
fix memory leak in Collection#unlock if CAS is not valid
Change-Id: I6a823326dca48f08659572489bf9f35f0ed36abd Reviewed-on: http://review.couchbase.org/c/php-couchbase/+/163452 Tested-by: Build Bot <[email protected]> Reviewed-by: Sergey Avseyev <[email protected]>
1 parent 2614e74 commit 8e173f9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/couchbase/bucket/unlock.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ PHP_METHOD(Collection, unlock)
8080
{
8181
lcb_STATUS err;
8282

83-
zend_string *id, *cas;
83+
zend_string *id;
84+
zend_string *cas;
8485
zval *options = NULL;
8586

8687
int rv = zend_parse_parameters(ZEND_NUM_ARGS(), "SS|O!", &id, &cas, &options, pcbc_unlock_options_ce);
@@ -100,6 +101,10 @@ PHP_METHOD(Collection, unlock)
100101
lcb_cmdunlock_cas(cmd, cas_val);
101102
zend_string_free(decoded);
102103
} else {
104+
if (decoded) {
105+
zend_string_free(decoded);
106+
}
107+
lcb_cmdunlock_destroy(cmd);
103108
throw_lcb_exception(LCB_ERR_INVALID_ARGUMENT, NULL);
104109
RETURN_NULL();
105110
}

0 commit comments

Comments
 (0)