forked from enlightenment/efl
ecore_x_selection: fix selection data freeing
This fixes valgrind reporting lost bytes when selecting text (e.g. in entry). Can be reproduced in any program that has entry: Simply run it with valgrind, select any text, and then exit. Fixed by properly freeing the selection data, since it is either cleared or replaced. Also, changed argument in sizeof since it didn't match the type of selections[in].
This commit is contained in:
parent
64e153ea7f
commit
3160b044fb
|
@ -624,6 +624,12 @@ _ecore_xcb_selection_set(Ecore_X_Window win,
|
|||
else
|
||||
return EINA_FALSE;
|
||||
|
||||
if (selections[in].data)
|
||||
{
|
||||
free(selections[in].data);
|
||||
memset(&selections[in], 0, sizeof(Ecore_X_Selection_Intern));
|
||||
}
|
||||
|
||||
if (data)
|
||||
{
|
||||
unsigned char *buff = NULL;
|
||||
|
@ -638,11 +644,6 @@ _ecore_xcb_selection_set(Ecore_X_Window win,
|
|||
memcpy(buff, data, size);
|
||||
_selections[in].data = buff;
|
||||
}
|
||||
else if (_selections[in].data)
|
||||
{
|
||||
free(_selections[in].data);
|
||||
memset(&_selections[in], 0, sizeof(Ecore_X_Selection_Data));
|
||||
}
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
|
|
@ -140,6 +140,12 @@ _ecore_x_selection_set(Window w,
|
|||
else
|
||||
return EINA_FALSE;
|
||||
|
||||
if (selections[in].data)
|
||||
{
|
||||
free(selections[in].data);
|
||||
memset(&selections[in], 0, sizeof(Ecore_X_Selection_Intern));
|
||||
}
|
||||
|
||||
if (data)
|
||||
{
|
||||
selections[in].win = w;
|
||||
|
@ -152,11 +158,6 @@ _ecore_x_selection_set(Window w,
|
|||
memcpy(buf, data, size);
|
||||
selections[in].data = buf;
|
||||
}
|
||||
else if (selections[in].data)
|
||||
{
|
||||
free(selections[in].data);
|
||||
memset(&selections[in], 0, sizeof(Ecore_X_Selection_Data));
|
||||
}
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue