awk: put at least one NUL between $n. Hopefully closes 337.
authorDenys Vlasenko <vda.linux@googlemail.com>
Mon, 18 May 2009 21:50:03 +0000 (23:50 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Mon, 18 May 2009 21:50:03 +0000 (23:50 +0200)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
editors/awk.c

index 924cfcfabd17ee5072a20197f3034360075291e5..cef73342c2d71a03f3590309a2e5a2d5c0c2cec7 100644 (file)
@@ -1571,13 +1571,14 @@ static int awk_split(const char *s, node *spl, char **slist)
                                n++; /* we saw yet another delimiter */
                        } else {
                                pmatch[0].rm_eo = l;
-                               if (s[l]) pmatch[0].rm_eo++;
+                               if (s[l])
+                                       pmatch[0].rm_eo++;
                        }
                        memcpy(s1, s, l);
                        /* make sure we remove *all* of the separator chars */
-                       while (l < pmatch[0].rm_eo) {
-                               s1[l++] = '\0';
-                       }
+                       do {
+                               s1[l] = '\0';
+                       } while (++l < pmatch[0].rm_eo);
                        nextword(&s1);
                        s += pmatch[0].rm_eo;
                } while (*s);