@@ -187,7 +187,6 @@ char *jwt_b64_url_encode(zend_string *input)
187
187
188
188
zend_string * jwt_b64_url_decode (const char * src )
189
189
{
190
- zend_string * result ;
191
190
char * new ;
192
191
int len , i , z ;
193
192
@@ -219,12 +218,7 @@ zend_string *jwt_b64_url_decode(const char *src)
219
218
new [i ] = '\0' ;
220
219
221
220
/* base64 decode */
222
- result = php_base64_decode_ex ((const unsigned char * )new , strlen (new ), 1 );
223
- if (result == NULL ) {
224
- zend_throw_exception (zend_ce_exception , "Base64 decode error" , 0 );
225
- }
226
-
227
- return result ;
221
+ return php_base64_decode_ex ((const unsigned char * )new , strlen (new ), 1 );
228
222
}
229
223
230
224
void jwt_parse_body (char * body , zval * return_value )
@@ -369,6 +363,11 @@ PHP_FUNCTION(jwt_decode)
369
363
zval zv ;
370
364
zend_string * json_h = jwt_b64_url_decode (head );
371
365
366
+ if (!json_h ) {
367
+ zend_throw_exception (zend_ce_exception , "Base64 decode error" , 0 );
368
+ goto decode_done ;
369
+ }
370
+
372
371
php_json_decode_ex (& zv , ZSTR_VAL (json_h ), ZSTR_LEN (json_h ), PHP_JSON_OBJECT_AS_ARRAY , 512 );
373
372
zend_string_free (json_h );
374
373
@@ -379,11 +378,11 @@ PHP_FUNCTION(jwt_decode)
379
378
380
379
if (strcmp (Z_STRVAL_P (zalg ), alg )) {
381
380
zend_throw_exception (zend_ce_exception , "Algorithm not allowed" , 0 );
382
- RETURN_FALSE ;
381
+ goto decode_done ;
383
382
}
384
383
} else {
385
384
zend_throw_exception (zend_ce_exception , "Json decode error" , 0 );
386
- RETURN_FALSE ;
385
+ goto decode_done ;
387
386
}
388
387
389
388
/* parse body */
0 commit comments