diff options
| author | Daniel P. Berrange <berrange@redhat.com> | 2017-01-25 11:10:53 +0000 |
|---|---|---|
| committer | Daniel P. Berrange <berrange@redhat.com> | 2017-01-26 10:26:18 +0000 |
| commit | 80fb34eda099e7cc519a91e9701ab3c0262717b3 (patch) | |
| tree | 44fc2cdb60950b04588b6ad65651b353170ae04b | |
| parent | c7f1cf01b8245762ca5864e835d84f6677ae8b1f (diff) | |
| download | focaccia-qemu-80fb34eda099e7cc519a91e9701ab3c0262717b3.tar.gz focaccia-qemu-80fb34eda099e7cc519a91e9701ab3c0262717b3.zip | |
io: fix possible double free of task error object
If a QIOTask has an error set and the calling code uses qio_task_propagate_error() to steal the reference to that Error object, the task would not clear its own reference. This would lead to a double-free when qio_task_free runs, if the caller had (correctly) freed the Error object they now owned. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
| -rw-r--r-- | io/task.c | 1 | ||||
| -rw-r--r-- | tests/test-io-task.c | 4 |
2 files changed, 4 insertions, 1 deletions
diff --git a/io/task.c b/io/task.c index 60bf1a94d5..3ce556017c 100644 --- a/io/task.c +++ b/io/task.c @@ -157,6 +157,7 @@ bool qio_task_propagate_error(QIOTask *task, { if (task->err) { error_propagate(errp, task->err); + task->err = NULL; return true; } diff --git a/tests/test-io-task.c b/tests/test-io-task.c index ff62272d5f..141aa2c55d 100644 --- a/tests/test-io-task.c +++ b/tests/test-io-task.c @@ -127,7 +127,7 @@ static void test_task_failure(void) g_assert(data.source == obj); g_assert(data.err == err); g_assert(data.freed == false); - + error_free(data.err); } @@ -238,6 +238,8 @@ static void test_task_thread_failure(void) g_assert(data.source == obj); g_assert(data.err != NULL); + error_free(data.err); + self = g_thread_self(); /* Make sure the test_task_thread_worker actually got |