Fix potential double free when we've had something in our clipboard, another app has claimed the clipboard, and the clipboard is now empty/disowned by all apps, and we try to paste the empty clipboard twice in NetSurf.
This commit is contained in:
parent
58540d83d8
commit
058acae43f
|
@ -285,6 +285,7 @@ void gui_get_clipboard(char **buffer, size_t *length)
|
||||||
void ro_gui_discard_clipboard_contents(void)
|
void ro_gui_discard_clipboard_contents(void)
|
||||||
{
|
{
|
||||||
free(clipboard);
|
free(clipboard);
|
||||||
|
clipboard = NULL;
|
||||||
clip_length = 0;
|
clip_length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -418,18 +419,20 @@ bool ro_gui_selection_prepare_paste_dataload(
|
||||||
size = ftell(fp);
|
size = ftell(fp);
|
||||||
fseek(fp, 0, SEEK_SET);
|
fseek(fp, 0, SEEK_SET);
|
||||||
|
|
||||||
local_cb = malloc(size);
|
if (size > 0) {
|
||||||
if (local_cb != NULL) {
|
local_cb = malloc(size);
|
||||||
fread(local_cb, 1, size, fp);
|
if (local_cb != NULL) {
|
||||||
|
fread(local_cb, 1, size, fp);
|
||||||
|
|
||||||
fclose(fp);
|
ret = utf8_from_local_encoding(local_cb, size,
|
||||||
|
&clipboard);
|
||||||
ret = utf8_from_local_encoding(local_cb, size,
|
if (ret == UTF8_CONVERT_OK) {
|
||||||
&clipboard);
|
clip_length = strlen(clipboard);
|
||||||
if (ret == UTF8_CONVERT_OK) {
|
}
|
||||||
clip_length = strlen(clipboard);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send DataLoadAck */
|
/* Send DataLoadAck */
|
||||||
|
|
Loading…
Reference in New Issue