diff --git a/src/fe-text/gui-entry.c b/src/fe-text/gui-entry.c index fe2bf89b..1148d076 100644 --- a/src/fe-text/gui-entry.c +++ b/src/fe-text/gui-entry.c @@ -337,11 +337,11 @@ void gui_entry_erase(GUI_ENTRY_REC *entry, int size) { g_return_if_fail(entry != NULL); - if (entry->pos < size || size == 0) + if (entry->pos < size) return; /* put erased text to cutbuffer */ - if (entry->cutbuffer_len < size) { + if (entry->cutbuffer == NULL || entry->cutbuffer_len < size) { g_free(entry->cutbuffer); entry->cutbuffer = g_new(unichar, size+1); } @@ -351,6 +351,11 @@ void gui_entry_erase(GUI_ENTRY_REC *entry, int size) memcpy(entry->cutbuffer, entry->text + entry->pos - size, size * sizeof(unichar)); + if (size == 0) { + /* we just wanted to clear the cutbuffer */ + return; + } + g_memmove(entry->text + entry->pos - size, entry->text + entry->pos, (entry->text_len-entry->pos+1) * sizeof(unichar));