@@ -187,7 +187,6 @@ char *jwt_b64_url_encode(zend_string *input)
187187
188188zend_string * jwt_b64_url_decode (const char * src )
189189{
190- zend_string * result ;
191190 char * new ;
192191 int len , i , z ;
193192
@@ -219,12 +218,7 @@ zend_string *jwt_b64_url_decode(const char *src)
219218 new [i ] = '\0' ;
220219
221220 /* 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 );
228222}
229223
230224void jwt_parse_body (char * body , zval * return_value )
@@ -369,6 +363,11 @@ PHP_FUNCTION(jwt_decode)
369363 zval zv ;
370364 zend_string * json_h = jwt_b64_url_decode (head );
371365
366+ if (!json_h ) {
367+ zend_throw_exception (zend_ce_exception , "Base64 decode error" , 0 );
368+ goto decode_done ;
369+ }
370+
372371 php_json_decode_ex (& zv , ZSTR_VAL (json_h ), ZSTR_LEN (json_h ), PHP_JSON_OBJECT_AS_ARRAY , 512 );
373372 zend_string_free (json_h );
374373
@@ -379,11 +378,11 @@ PHP_FUNCTION(jwt_decode)
379378
380379 if (strcmp (Z_STRVAL_P (zalg ), alg )) {
381380 zend_throw_exception (zend_ce_exception , "Algorithm not allowed" , 0 );
382- RETURN_FALSE ;
381+ goto decode_done ;
383382 }
384383 } else {
385384 zend_throw_exception (zend_ce_exception , "Json decode error" , 0 );
386- RETURN_FALSE ;
385+ goto decode_done ;
387386 }
388387
389388 /* parse body */
0 commit comments