Skip to content

Commit 9a012bf

Browse files
rscharfegitster
authored andcommitted
utf8: release strbuf on error return in strbuf_utf8_replace()
Signed-off-by: Rene Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 460c7eb commit 9a012bf

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

utf8.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ void strbuf_utf8_replace(struct strbuf *sb_src, int pos, int width,
381381
old = src;
382382
n = utf8_width((const char**)&src, NULL);
383383
if (!src) /* broken utf-8, do nothing */
384-
return;
384+
goto out;
385385
if (n && w >= pos && w < pos + width) {
386386
if (subst) {
387387
memcpy(dst, subst, subst_len);
@@ -397,6 +397,7 @@ void strbuf_utf8_replace(struct strbuf *sb_src, int pos, int width,
397397
}
398398
strbuf_setlen(&sb_dst, dst - sb_dst.buf);
399399
strbuf_swap(sb_src, &sb_dst);
400+
out:
400401
strbuf_release(&sb_dst);
401402
}
402403

0 commit comments

Comments
 (0)