diff --git a/ChangeLog b/ChangeLog index 5465a5a67bf45cee2c66444d2442a090162ac3f3..db9976ffbea8974b6074b62428a4ec7453c7f3f6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -27,6 +27,10 @@ General - Messy loops replaced with memset calls (Rocco). do_alt_speller() - Added code to parse multi-word alt_speller strings. + - Fix initialization before fork() (Rocco). +- winio.c: + nanogetstr() + - Sanity check for x overrunning the string buffer len. nano 0.9.99pre1 - 01/17/2001 General diff --git a/nano.c b/nano.c index 6df7ced9c492661261a6240bfe61aae423a3ff32..c45441689bf3327501e1ad905b0feaf56c67ece6 100644 --- a/nano.c +++ b/nano.c @@ -1322,24 +1322,23 @@ int do_alt_speller(char *file_name) endwin(); - /* Start a new process for the alternate speller */ + /* Set up an argument list to pass the execvp function */ + if (spellargs == NULL) { + spellargs = nmalloc(arglen * sizeof(char *)); + + spellargs[0] = strtok(alt_speller, " "); + while ((ptr = strtok(NULL, " ")) != NULL) { + arglen++; + spellargs = nrealloc(spellargs, arglen * sizeof(char *)); + spellargs[arglen - 3] = ptr; + } + spellargs[arglen - 1] = NULL; + } + spellargs[arglen - 2] = file_name; + /* Start a new process for the alternate speller */ if ( (pid_spell = fork()) == 0) { - /* Set up an argument list to pass the execvp function */ - if (spellargs == NULL) { - spellargs = nmalloc(arglen * sizeof(char *)); - - spellargs[0] = strtok(alt_speller, " "); - while ((ptr = strtok(NULL, " ")) != NULL) { - arglen++; - spellargs = nrealloc(spellargs, arglen * sizeof(char *)); - spellargs[arglen - 3] = ptr; - } - spellargs[arglen - 1] = NULL; - } - spellargs[arglen - 2] = file_name; - /* Start alternate spell program, we are using the PATH here!?!? */ execvp(spellargs[0], spellargs); diff --git a/winio.c b/winio.c index 06e6530883b11b0d22632ddc5f972e1df4cde0c6..5f10bf716e64370c01808538339f69afa5b40cb9 100644 --- a/winio.c +++ b/winio.c @@ -353,6 +353,8 @@ int nanogetstr(int allowtabs, char *buf, char *def, shortcut s[], int slen, inputbuf = input_tab(inputbuf, (x - x_left), &tabbed, &shift); x += shift; + if (x - x_left > strlen(inputbuf)) + x = strlen(inputbuf) + x_left; nanoget_repaint(buf, inputbuf, x); } break;