acme: do not pass null pointers where disallowed

The C standards disallow passing null pointers to memmove and memcmp.

Change-Id: I1c88c2adbc32a23ef742f206038b8f7c4e0540c7
This commit is contained in:
Neven Sajko 2016-05-28 15:00:06 +02:00 committed by David du Colombier
parent f77d12f8d8
commit d6f8c236b8
2 changed files with 4 additions and 1 deletions

View file

@ -276,6 +276,8 @@ runeeq(Rune *s1, uint n1, Rune *s2, uint n2)
{ {
if(n1 != n2) if(n1 != n2)
return FALSE; return FALSE;
if(n1 == 0)
return TRUE;
return memcmp(s1, s2, n1*sizeof(Rune)) == 0; return memcmp(s1, s2, n1*sizeof(Rune)) == 0;
} }

View file

@ -476,7 +476,8 @@ winsettag1(Window *w)
/* compute the text for the whole tag, replacing current only if it differs */ /* compute the text for the whole tag, replacing current only if it differs */
new = runemalloc(w->body.file->nname+100); new = runemalloc(w->body.file->nname+100);
i = 0; i = 0;
runemove(new+i, w->body.file->name, w->body.file->nname); if(w->body.file->nname != 0)
runemove(new, w->body.file->name, w->body.file->nname);
i += w->body.file->nname; i += w->body.file->nname;
runemove(new+i, Ldelsnarf, 10); runemove(new+i, Ldelsnarf, 10);
i += 10; i += 10;