Skip to content

Commit c06f501

Browse files
committed
Fix Segmentation fault (core dumped)
1 parent 500c19f commit c06f501

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

jwt.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ PHP_FUNCTION(jwt_encode)
352352
zend_string *key = NULL;
353353
smart_str json_header = {0}, json_claims = {0}, segments = {0};
354354

355-
char *sig = NULL, *alg = "HS256";
355+
char *sig = NULL, *alg = NULL;
356356
unsigned int sig_len;
357357
size_t alg_len;
358358
jwt_t *jwt = NULL;
@@ -364,6 +364,9 @@ PHP_FUNCTION(jwt_encode)
364364
/* init jwt */
365365
jwt_new(&jwt);
366366

367+
/* not set algorithm */
368+
alg = (alg == NULL) ? "HS256" : alg;
369+
367370
/* check algorithm */
368371
jwt->alg = jwt_str_alg(alg);
369372

0 commit comments

Comments
 (0)