winex11: Fix memory leak on realloc failure in import_xdnd_selection (cppcheck).

This commit is contained in:
Alex Henrie 2022-11-28 22:22:45 -07:00 committed by Alexandre Julliard
parent e7ba00c7ca
commit 4aac4e7c67

View file

@ -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);