fixes another leak in string replace function

Sun, 29 Dec 2019 12:52:56 +0100

author
Mike Becker <universe@uap-core.de>
date
Sun, 29 Dec 2019 12:52:56 +0100
changeset 380
2c9a5aebaee1
parent 379
477404eb380e
child 381
f5421bb2c8d1

fixes another leak in string replace function

src/string.c file | annotate | diff | comparison | revisions
--- a/src/string.c	Sun Dec 29 11:30:39 2019 +0100
+++ b/src/string.c	Sun Dec 29 12:52:56 2019 +0100
@@ -712,7 +712,10 @@
             if (curbuf->len == ibuflen) {
                 struct scstrreplace_ibuf *nextbuf =
                         calloc(1, sizeof(struct scstrreplace_ibuf));
-                if (!nextbuf) return sstrn(NULL, 0);
+                if (!nextbuf) {
+                    scstrrepl_free_ibuf(firstbuf);
+                    return sstrn(NULL, 0);
+                }
                 nextbuf->buf = calloc(ibuflen, sizeof(size_t));
                 if (!nextbuf->buf) {
                     free(nextbuf);

mercurial