serial: ensure response array is empty before setting cached reply

This commit is contained in:
Aleksander Morgado
2011-04-12 16:32:11 +02:00
committed by Dan Williams
parent d05c87e4c8
commit 48c7dac009

View File

@@ -571,6 +571,17 @@ mm_serial_port_queue_process (gpointer data)
const GByteArray *cached = mm_serial_port_get_cached_reply (self, info->command);
if (cached) {
/* Ensure the response array is fully empty before setting the
* cached response. */
if (priv->response->len > 0) {
g_warning ("%s: (%s) response array is not empty when using "
"cached reply, cleaning up %u bytes",
__func__,
mm_port_get_device (MM_PORT (self)),
priv->response->len);
g_byte_array_set_size (priv->response, 0);
}
g_byte_array_append (priv->response, cached->data, cached->len);
mm_serial_port_got_response (self, NULL);
return FALSE;