summaryrefslogtreecommitdiff
path: root/vdagent
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@gmail.com>2013-07-17 20:42:31 +0200
committerMarc-André Lureau <marcandre.lureau@gmail.com>2013-07-17 20:45:21 +0200
commitb9d6baec2d346e37798dd1892f6ae95ac9d6c9ef (patch)
treea0892b4890fa90b3e6a321568101b25c3473572d /vdagent
parent462295d9f84658aa7b43401fe7d1373cb3b0fc2d (diff)
Fix task could be used uninitialized
Diffstat (limited to 'vdagent')
-rw-r--r--vdagent/file_xfer.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/vdagent/file_xfer.cpp b/vdagent/file_xfer.cpp
index 6ba15a3..9d2f3c5 100644
--- a/vdagent/file_xfer.cpp
+++ b/vdagent/file_xfer.cpp
@@ -82,7 +82,7 @@ bool FileXfer::handle_data(VDAgentFileXferDataMessage* data,
VDAgentFileXferStatusMessage* status)
{
FileXferTasks::iterator iter;
- FileXferTask* task;
+ FileXferTask* task = NULL;
DWORD written;
status->id = data->id;
@@ -108,13 +108,17 @@ bool FileXfer::handle_data(VDAgentFileXferDataMessage* data,
}
vd_printf("%u completed", iter->first);
status->result = VD_AGENT_FILE_XFER_STATUS_SUCCESS;
+
fin:
- CloseHandle(task->handle);
- if (status->result != VD_AGENT_FILE_XFER_STATUS_SUCCESS) {
- DeleteFileA(task->name);
+ if (task) {
+ CloseHandle(task->handle);
+ if (status->result != VD_AGENT_FILE_XFER_STATUS_SUCCESS) {
+ DeleteFileA(task->name);
+ }
+ _tasks.erase(iter);
+ delete task;
}
- _tasks.erase(iter);
- delete task;
+
return true;
}