w3m

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/w3m.git/
Log | Files | Refs | README

commit be6c16f46c613ad71ac6758b4e2ae330f933a3f2
parent 8200d512c9e91272fe764a26ba7c5a99098d2bbb
Author: ukai <ukai>
Date:   Mon, 19 Nov 2001 07:58:24 +0000

[w3m-dev 02436] fix segmentation fault in main.c
  closes: #482763 segmentation fault in main.c

Diffstat:
MChangeLog | 5+++++
Mmain.c | 26+++++++++++---------------
2 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,8 @@ +2001-11-19 Hironori Sakamoto <hsaka@mth.biglobe.ne.jp> + + * main.c (GetWord): [w3m-dev 02436] fix segmentation fault in main.c + closes: #482763 segmentation fault in main.c + 2001-11-19 Fumitoshi UKAI <ukai@debian.or.jp> * gc/.cvsignore: diff --git a/main.c b/main.c @@ -4416,27 +4416,23 @@ GetWord(Buffer * buf) { Line *l = buf->currentLine; char *lb; - int i, b, e, pos = buf->pos; + int b, e; if (l == NULL) return NULL; lb = l->lineBuf; - i = pos; - while (!IS_ALPHA(lb[i]) && i >= 0) - i--; - pos = i; - while (IS_ALPHA(lb[i]) && i >= 0) - i--; - i++; - if (!IS_ALPHA(lb[i])) + e = buf->pos; + while (e > 0 && !IS_ALPHA(lb[e])) + e--; + if (!IS_ALPHA(lb[e])) return NULL; - b = i; - i = pos; - while (IS_ALPHA(lb[i]) && i <= l->len - 1) - i++; - e = i - 1; - return Strnew_charp_n(&lb[b], e - b + 1)->ptr; + b = e; + while (b > 0 && IS_ALPHA(lb[b-1])) + b--; + while (e < l->len && IS_ALPHA(lb[e])) + e++; + return Strnew_charp_n(&lb[b], e - b)->ptr; } #ifdef DICT