Skip to content

Commit da72f68

Browse files
committed
Fixed: smart_str_free() bug
1 parent 1a4155b commit da72f68

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

jwt.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -630,9 +630,8 @@ static void php_jwt_decode(INTERNAL_FUNCTION_PARAMETERS) {
630630

631631
if (jwt_verify(jwt, sig)) {
632632
zend_throw_exception(jwt_signature_invalid_cex, "Signature verification failed", 0);
633+
goto decode_done;
633634
}
634-
635-
smart_str_free(&buf);
636635
}
637636

638637
/* verify body */
@@ -643,6 +642,7 @@ static void php_jwt_decode(INTERNAL_FUNCTION_PARAMETERS) {
643642
decode_done:
644643
efree(head);
645644
jwt_free(jwt);
645+
smart_str_free(&buf);
646646
}
647647

648648
/* function jwt_encode() */

tests/015.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ $hmackey = "example-hmac-key";
88

99
try {
1010
$decoded_token = jwt_decode('eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJkYXRhIjp7Im5hbWUiOiJaaUhhbmcgR2FvIiwiYWRtaW4iOnRydWV9LCJzdWIiOiIxMjM0NTY3ODkwIiwibmJmIjoxNTQ2ODQ4CJhdWQiOiJ5eSJ9.fDqiF-cCIvlcscIdz7dcFJoYGBcvHtI6MWB5IWG0VHA', $hmackey, ['algorithm' => 'HS256']);
11-
} catch (UnexpectedValueException $e) {
11+
} catch (SignatureInvalidException $e) {
1212
// Handle expired token
1313
echo "FAIL\n";
1414
}

0 commit comments

Comments
 (0)