From: Michael Tremer Date: Wed, 25 Jun 2025 10:58:26 +0000 (+0000) Subject: xfer: Don't attempt to parse a JSON response when there is no data X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=22969a14d002d0c6707a98a239a64230eb0caa67;p=pakfire.git xfer: Don't attempt to parse a JSON response when there is no data Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/xfer.c b/src/pakfire/xfer.c index 9cbc8489..8a398b0a 100644 --- a/src/pakfire/xfer.c +++ b/src/pakfire/xfer.c @@ -1015,17 +1015,19 @@ static int pakfire_xfer_call_response_callback(struct pakfire_xfer* self, pakfir int r; // Parse the API response - switch (code) { - case PAKFIRE_XFER_OK: - r = pakfire_json_parse(&response, &error, self->output.buffer, self->output.length); - if (r < 0) { - ERROR(self->ctx, "Failed to parse JSON response: %s\n", error); - goto ERROR; - } - break; + if (self->output.length) { + switch (code) { + case PAKFIRE_XFER_OK: + r = pakfire_json_parse(&response, &error, self->output.buffer, self->output.length); + if (r < 0) { + ERROR(self->ctx, "Failed to parse JSON response: %s\n", error); + goto ERROR; + } + break; - default: - break; + default: + break; + } } // Run the callback