]> git.ipfire.org Git - pakfire.git/commitdiff
jwt: Free the decoded payload
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 27 Jun 2025 07:19:48 +0000 (07:19 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 27 Jun 2025 07:19:48 +0000 (07:19 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/jwt.c

index 4a89fba312da4245566984b273121b6638ee4103..f71d03215f633c747d2ecbb75344ff1a77bfb448 100644 (file)
@@ -95,14 +95,18 @@ int pakfire_jwt_payload(const char* token, struct json_object** payload) {
        // Decode the payload
        r = pakfire_jwt_decode_payload(&p, &l, token);
        if (r < 0)
-               return r;
+               goto ERROR;
 
        // Parse the JSON
        r = pakfire_json_parse(payload, NULL, p, l);
        if (r < 0)
-               return r;
+               goto ERROR;
 
-       return 0;
+ERROR:
+       if (p)
+               free(p);
+
+       return r;
 }
 
 time_t pakfire_jwt_expires_at(const char* token) {