From: Michael Tremer Date: Fri, 31 Jan 2025 12:32:30 +0000 (+0000) Subject: mirrorlist: Don't free the JSON object when checking it's type X-Git-Tag: 0.9.30~215 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dfebdcf8a51eec1070cef27ad806d8160f5010b6;p=pakfire.git mirrorlist: Don't free the JSON object when checking it's type Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/mirrorlist.c b/src/pakfire/mirrorlist.c index fde171da..b1da8bba 100644 --- a/src/pakfire/mirrorlist.c +++ b/src/pakfire/mirrorlist.c @@ -25,6 +25,7 @@ #include #include #include +#include #include struct pakfire_mirrorlist { @@ -93,33 +94,26 @@ struct pakfire_mirrorlist* pakfire_mirrorlist_unref(struct pakfire_mirrorlist* l static int pakfire_mirrorlist_check_mirrorlist(struct pakfire_mirrorlist* list, struct json_object* root) { struct json_object* typeobj = NULL; - int r = 1; + int r; r = json_object_object_get_ex(root, "type", &typeobj); if (!r) { ERROR(list->ctx, "mirrorlist does not have a 'type' attribute\n"); - goto ERROR; + return -EBADMSG; } const char* type = json_object_get_string(typeobj); if (!type) { ERROR(list->ctx, "mirrorlist has an empty or unknown 'type' attribute\n"); - goto ERROR; + return -EBADMSG; } - if (strcmp(type, "mirrorlist") != 0) { + if (!pakfire_string_equals(type, "mirrorlist")) { ERROR(list->ctx, "Unexpected type: %s\n", type); - goto ERROR; + return -EBADMSG; } - // Success - r = 0; - -ERROR: - if (typeobj) - json_object_put(typeobj); - - return r; + return 0; } static int pakfire_mirrorlist_add_mirror_from_url(