Commit 1a029e30 authored by Claudio Saavedra's avatar Claudio Saavedra

WebSockets: plug a couple of leaks in case of error with the deflate extension

Also remove a spurious unref in the caller while handling the error,
which shouldn't be needed as the extension returns NULL in case of
error.
parent 2a02994b
Pipeline #109678 passed with stage
in 1 minute and 3 seconds
......@@ -1077,8 +1077,6 @@ process_frame (SoupWebsocketConnection *self)
filtered_bytes = soup_websocket_extension_process_incoming_message (extension, self->pv->incoming->data, filtered_bytes, &error);
if (error) {
emit_error_and_close (self, error, FALSE);
g_bytes_unref (filtered_bytes);
return FALSE;
}
}
......
......@@ -355,6 +355,8 @@ soup_websocket_extension_deflate_process_outgoing_message (SoupWebsocketExtensio
bytes_written += write_remaining - priv->deflater.zstream.avail_out;
} while (result == Z_OK);
g_bytes_unref (payload);
if (result != Z_BUF_ERROR || bytes_written < 4) {
g_set_error_literal (error,
SOUP_WEBSOCKET_ERROR,
......@@ -368,8 +370,6 @@ soup_websocket_extension_deflate_process_outgoing_message (SoupWebsocketExtensio
/* Remove 4 octets (that are 0x00 0x00 0xff 0xff) from the tail end. */
g_byte_array_set_size (buffer, bytes_written - 4);
g_bytes_unref (payload);
deflater_reset (&priv->deflater);
return g_byte_array_free_to_bytes (buffer);
......@@ -410,6 +410,7 @@ soup_websocket_extension_deflate_process_incoming_message (SoupWebsocketExtensio
SOUP_WEBSOCKET_ERROR,
SOUP_WEBSOCKET_CLOSE_PROTOCOL_ERROR,
"Received a non-first frame with RSV1 flag set");
g_bytes_unref (payload);
return NULL;
}
......@@ -467,6 +468,8 @@ soup_websocket_extension_deflate_process_incoming_message (SoupWebsocketExtensio
break;
} while (result == Z_OK || result == Z_BUF_ERROR);
g_bytes_unref (payload);
if (result != Z_OK && result != Z_BUF_ERROR) {
priv->inflater.uncompress_ongoing = FALSE;
g_set_error_literal (error,
......@@ -480,8 +483,6 @@ soup_websocket_extension_deflate_process_incoming_message (SoupWebsocketExtensio
g_byte_array_set_size (buffer, bytes_written);
g_bytes_unref (payload);
return g_byte_array_free_to_bytes (buffer);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment