From 7016847e3bb8325e09f25f3cd95ccb0d70c8fa23 Mon Sep 17 00:00:00 2001 From: Zhang Zhaolong Date: Wed, 11 Mar 2015 16:37:28 +0800 Subject: [PATCH] wf_cliprdr: fix potential memory leak. Signed-off-by: Zhang Zhaolong --- client/Windows/wf_cliprdr.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/client/Windows/wf_cliprdr.c b/client/Windows/wf_cliprdr.c index edbc0b906..c4967951a 100644 --- a/client/Windows/wf_cliprdr.c +++ b/client/Windows/wf_cliprdr.c @@ -1359,13 +1359,18 @@ static void wf_cliprdr_array_ensure_capacity(wfClipboard* clipboard) WCHAR **new_name; new_size = clipboard->file_array_size * 2; + new_fd = (FILEDESCRIPTORW**) realloc(clipboard->fileDescriptor, new_size * sizeof(FILEDESCRIPTORW*)); + if (new_fd) + clipboard->fileDescriptor = new_fd; + new_name = (WCHAR**) realloc(clipboard->file_names, new_size * sizeof(WCHAR*)); + if (new_name) + clipboard->file_names = new_name; + if (!new_fd || !new_name) return; - clipboard->fileDescriptor = new_fd; - clipboard->file_names = new_name; clipboard->file_array_size *= new_size; } }