|
|
f95c64 |
From b93c4cae1aebda786a478677d6364308e4579ade Mon Sep 17 00:00:00 2001
|
|
|
f95c64 |
From: Victor Toso <victortoso@redhat.com>
|
|
|
f95c64 |
Date: Sat, 25 Jun 2022 00:29:12 +0200
|
|
|
f95c64 |
Subject: [PATCH 2/2] usbredirparser: reset parser's fields on unserialize
|
|
|
f95c64 |
Content-type: text/plain
|
|
|
f95c64 |
|
|
|
f95c64 |
This is a followup from previous commit and fixes the following leak.
|
|
|
f95c64 |
|
|
|
f95c64 |
| 104 (24 direct, 80 indirect) bytes in 1 blocks are definitely lost in loss record 15 of 19
|
|
|
f95c64 |
| at 0x484A464: calloc (vg_replace_malloc.c:1328)
|
|
|
f95c64 |
| by 0x485A238: usbredirparser_queue (usbredirparser.c:1235)
|
|
|
f95c64 |
| by 0x485A571: usbredirparser_init (usbredirparser.c:227)
|
|
|
f95c64 |
| by 0x40130B: get_usbredirparser (serializer.c:77)
|
|
|
f95c64 |
| by 0x401379: simple (serializer.c:95)
|
|
|
f95c64 |
| by 0x48FA3DD: ??? (in /usr/lib64/libglib-2.0.so.0.7200.2)
|
|
|
f95c64 |
| by 0x48FA144: ??? (in /usr/lib64/libglib-2.0.so.0.7200.2)
|
|
|
f95c64 |
| by 0x48FA8E1: g_test_run_suite (in /usr/lib64/libglib-2.0.so.0.7200.2)
|
|
|
f95c64 |
| by 0x48FA94C: g_test_run (in /usr/lib64/libglib-2.0.so.0.7200.2)
|
|
|
f95c64 |
| by 0x401161: main (serializer.c:112)
|
|
|
f95c64 |
|
|
|
|
f95c64 |
| LEAK SUMMARY:
|
|
|
f95c64 |
| definitely lost: 24 bytes in 1 blocks
|
|
|
f95c64 |
| indirectly lost: 80 bytes in 1 blocks
|
|
|
f95c64 |
| possibly lost: 0 bytes in 0 blocks
|
|
|
f95c64 |
| still reachable: 25,500 bytes in 17 blocks
|
|
|
f95c64 |
| suppressed: 0 bytes in 0 blocks
|
|
|
f95c64 |
| Reachable blocks (those to which a pointer was found) are not shown.
|
|
|
f95c64 |
| To see them, rerun with: --leak-check=full --show-leak-kinds=all
|
|
|
f95c64 |
|
|
|
f95c64 |
Signed-off-by: Victor Toso <victortoso@redhat.com>
|
|
|
f95c64 |
---
|
|
|
f95c64 |
usbredirparser/usbredirparser.c | 15 +++++++++++++++
|
|
|
f95c64 |
1 file changed, 15 insertions(+)
|
|
|
f95c64 |
|
|
|
f95c64 |
diff --git a/usbredirparser/usbredirparser.c b/usbredirparser/usbredirparser.c
|
|
|
f95c64 |
index a5dd0e7..9bfc27c 100644
|
|
|
f95c64 |
--- a/usbredirparser/usbredirparser.c
|
|
|
f95c64 |
+++ b/usbredirparser/usbredirparser.c
|
|
|
f95c64 |
@@ -1823,6 +1823,21 @@ int usbredirparser_unserialize(struct usbredirparser *parser_pub,
|
|
|
f95c64 |
return -1;
|
|
|
f95c64 |
}
|
|
|
f95c64 |
|
|
|
f95c64 |
+ {
|
|
|
f95c64 |
+ /* We need to reset parser's state to receive unserialized
|
|
|
f95c64 |
+ * data. */
|
|
|
f95c64 |
+ struct usbredirparser_buf *wbuf = parser->write_buf;
|
|
|
f95c64 |
+ while (wbuf) {
|
|
|
f95c64 |
+ struct usbredirparser_buf *next_wbuf = wbuf->next;
|
|
|
f95c64 |
+ free(wbuf->buf);
|
|
|
f95c64 |
+ free(wbuf);
|
|
|
f95c64 |
+ wbuf = next_wbuf;
|
|
|
f95c64 |
+ }
|
|
|
f95c64 |
+ parser->write_buf = NULL;
|
|
|
f95c64 |
+ parser->write_buf_count = 0;
|
|
|
f95c64 |
+ parser->write_buf_total_size = 0;
|
|
|
f95c64 |
+ }
|
|
|
f95c64 |
+
|
|
|
f95c64 |
if (unserialize_int(parser, &state, &remain, &i, "length")) {
|
|
|
f95c64 |
usbredirparser_assert_invariants(parser);
|
|
|
f95c64 |
return -1;
|
|
|
f95c64 |
--
|
|
|
f95c64 |
2.37.1
|
|
|
f95c64 |
|