]> git.ipfire.org Git - pakfire.git/commitdiff
xfer: Don't attempt to parse a JSON response when there is no data
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 25 Jun 2025 10:58:26 +0000 (10:58 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 25 Jun 2025 10:58:26 +0000 (10:58 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/xfer.c

index 9cbc8489dce55907c88524445064a5371a8c7f5d..8a398b0a12b1e96e6026e0955da57bf7f1850b1e 100644 (file)
@@ -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