input: after reallocating a string, do not write to its old address
The old address has become invalid, and probably does not have enough room for the write, thus causing a crash. This fixes https://savannah.gnu.org/bugs/?57858. Bug existed since commit 8625609c from two days ago.
Этот коммит содержится в:
родитель
8b2b9654ab
Коммит
bb1a0bd86c
@ -1639,7 +1639,6 @@ void process_a_keystroke(void)
|
|||||||
void inject(char *burst, size_t count)
|
void inject(char *burst, size_t count)
|
||||||
{
|
{
|
||||||
size_t datalen = strlen(openfile->current->data);
|
size_t datalen = strlen(openfile->current->data);
|
||||||
char *thepoint = openfile->current->data + openfile->current_x;
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
size_t original_row = 0, old_amount = 0;
|
size_t original_row = 0, old_amount = 0;
|
||||||
|
|
||||||
@ -1667,8 +1666,10 @@ void inject(char *burst, size_t count)
|
|||||||
/* Make room for the new bytes and copy them into the line. */
|
/* Make room for the new bytes and copy them into the line. */
|
||||||
openfile->current->data = charealloc(openfile->current->data,
|
openfile->current->data = charealloc(openfile->current->data,
|
||||||
datalen + count + 1);
|
datalen + count + 1);
|
||||||
memmove(thepoint + count, thepoint, datalen - openfile->current_x + 1);
|
memmove(openfile->current->data + openfile->current_x + count,
|
||||||
strncpy(thepoint, burst, count);
|
openfile->current->data + openfile->current_x,
|
||||||
|
datalen - openfile->current_x + 1);
|
||||||
|
strncpy(openfile->current->data + openfile->current_x, burst, count);
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
/* When the mark is to the right of the cursor, compensate its position. */
|
/* When the mark is to the right of the cursor, compensate its position. */
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user