Fix memmove arithemtic error. - sam - An updated version of the sam text editor.
(HTM) git clone git://vernunftzentrum.de/sam.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
(DIR) commit 258b74b67b0885d97c6ea71e5d8c231cb5a92ded
(DIR) parent 1f4860ac9d58b65870094a6867a7b16c8f7c2f48
(HTM) Author: Rob King <jking@deadpixi.com>
Date: Sun, 25 Sep 2016 22:15:51 -0500
Fix memmove arithemtic error.
Diffstat:
libXg/gwin.c | 2 +-
libframe/frbox.c | 5 +++--
2 files changed, 4 insertions(+), 3 deletions(-)
---
(DIR) diff --git a/libXg/gwin.c b/libXg/gwin.c
@@ -158,7 +158,7 @@ Mappingaction(Widget w, XEvent *e, String *p, Cardinal *np)
#define STUFFCOMPOSE() \
f = ((GwinWidget)w)->gwin.gotchar; \
if (f) \
- for (c = 0; c < composing; c++) \
+ for (int c = 0; c < composing; c++) \
(*f)(compose[c], 0, Tcurrent, 0, 0, NULL)
typedef struct Unikeysym Unikeysym;
(DIR) diff --git a/libframe/frbox.c b/libframe/frbox.c
@@ -117,9 +117,10 @@ chopbox(Frame *f, Frbox *b, int n) /* drop first n chars; no allocation done */
{
if(b->nrune<0 || b->nrune<n)
berror("chopbox");
- memmove(b->a.ptr, runeindex(b->a.ptr, n), b->nrune - n);
+
+ uchar *ri = runeindex(b->a.ptr, n);
+ memmove(b->a.ptr, ri, strlen((char *)ri) + 1);
b->nrune -= n;
- b->a.ptr[b->nrune] = 0;
b->wid = strwidth(f->font, (char *)b->a.ptr);
}