From f7dfc937ebc7317fd3ff168e062d32119913d7ae Mon Sep 17 00:00:00 2001 From: xXx-caillou-xXx Date: Tue, 19 Dec 2017 18:14:41 +0100 Subject: Fix a segfault related to cookies Apparently, PHP doesn't like when you're trying to save some memory when you're playing with strings.--- src/sp_cookie_encryption.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/sp_cookie_encryption.c') diff --git a/src/sp_cookie_encryption.c b/src/sp_cookie_encryption.c index 2bb305f..2d6c938 100644 --- a/src/sp_cookie_encryption.c +++ b/src/sp_cookie_encryption.c @@ -209,10 +209,10 @@ PHP_FUNCTION(sp_setcookie) { cookie_samesite = (cookie_node->samesite == lax) ? SAMESITE_COOKIE_FORMAT SP_TOKEN_SAMESITE_LAX : SAMESITE_COOKIE_FORMAT SP_TOKEN_SAMESITE_STRICT; /* Concatenating everything, as is in PHP internals */ - samesite = zend_string_extend(path, ZSTR_LEN(path) + strlen(cookie_samesite) + 1, 0); + samesite = zend_string_init(ZSTR_VAL(path), ZSTR_LEN(path), 0); + samesite = zend_string_extend(samesite, ZSTR_LEN(path) + strlen(cookie_samesite) + 1, 0); memcpy(ZSTR_VAL(samesite) + ZSTR_LEN(path), cookie_samesite, strlen(cookie_samesite) + 1); ZVAL_STR_COPY(¶ms[3], samesite); - zend_string_release(path); } else if (path) { ZVAL_STR_COPY(¶ms[3], path); } -- cgit v1.3