Module: wine
Branch: master
Commit: 4aac4e7c67ace84ca3bd732cb292eca54502ddb4
URL:
https://gitlab.winehq.org/wine/wine/-/commit/4aac4e7c67ace84ca3bd732cb292ec…
Author: Alex Henrie <alexhenrie24(a)gmail.com>
Date: Mon Nov 28 22:22:45 2022 -0700
winex11: Fix memory leak on realloc failure in import_xdnd_selection (cppcheck).
---
dlls/winex11.drv/clipboard.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/dlls/winex11.drv/clipboard.c b/dlls/winex11.drv/clipboard.c
index e91368d69e7..959b59825e1 100644
--- a/dlls/winex11.drv/clipboard.c
+++ b/dlls/winex11.drv/clipboard.c
@@ -1285,7 +1285,7 @@ struct format_entry *import_xdnd_selection( Display *display, Window
win, Atom s
UINT i;
void *data;
struct clipboard_format *format;
- struct format_entry *ret = NULL, *entry;
+ struct format_entry *ret = NULL, *tmp, *entry;
BOOL have_hdrop = FALSE;
register_x11_formats( targets, count );
@@ -1310,7 +1310,8 @@ struct format_entry *import_xdnd_selection( Display *display, Window
win, Atom s
entry_size = (FIELD_OFFSET( struct format_entry, data[size] ) + 7) & ~7;
if (buf_size < size + entry_size)
{
- if (!(ret = realloc( ret, *ret_size + entry_size + 1024 ))) continue;
+ if (!(tmp = realloc( ret, *ret_size + entry_size + 1024 ))) continue;
+ ret = tmp;
buf_size = *ret_size + entry_size + 1024; /* extra space for following
entries */
}
entry = (struct format_entry *)((char *)ret + *ret_size);