tacme: do not pass null pointers where disallowed - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit d6f8c236b8c601781cef6f8521fd47dffa1758b4
 (DIR) parent f77d12f8d8a822aae41b835c0cca050928c58221
 (HTM) Author: Neven Sajko <nsajko@gmail.com>
       Date:   Sat, 28 May 2016 15:00:06 +0200
       
       acme: do not pass null pointers where disallowed
       
       The C standards disallow passing null pointers to memmove and memcmp.
       
       Change-Id: I1c88c2adbc32a23ef742f206038b8f7c4e0540c7
       
       Diffstat:
         M src/cmd/acme/util.c                 |       2 ++
         M src/cmd/acme/wind.c                 |       3 ++-
       
       2 files changed, 4 insertions(+), 1 deletion(-)
       ---
 (DIR) diff --git a/src/cmd/acme/util.c b/src/cmd/acme/util.c
       t@@ -276,6 +276,8 @@ runeeq(Rune *s1, uint n1, Rune *s2, uint n2)
        {
                if(n1 != n2)
                        return FALSE;
       +        if(n1 == 0)
       +                return TRUE;
                return memcmp(s1, s2, n1*sizeof(Rune)) == 0;
        }
        
 (DIR) diff --git a/src/cmd/acme/wind.c b/src/cmd/acme/wind.c
       t@@ -476,7 +476,8 @@ winsettag1(Window *w)
                /* compute the text for the whole tag, replacing current only if it differs */
                new = runemalloc(w->body.file->nname+100);
                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;
                runemove(new+i, Ldelsnarf, 10);
                i += 10;