1
0
mirror of https://github.com/irssi/irssi.git synced 2024-11-03 04:27:19 -05:00

improve padding performance

Credit to Oss-Fuzz
This commit is contained in:
ailin-nemui 2018-02-13 12:31:22 +01:00
parent c01f6df957
commit a6fcd5432e

View File

@ -337,11 +337,14 @@ char *get_alignment(const char *text, int align, int flags, char pad)
/* add pad characters */
if (flags & ALIGN_PAD) {
while (string_width(str->str, policy) < align) {
int pad_len = align - string_width(str->str, policy);
if (pad_len > 0) {
char *pad_full = g_strnfill(pad_len, pad);
if (flags & ALIGN_RIGHT)
g_string_prepend_c(str, pad);
g_string_prepend(str, pad_full);
else
g_string_append_c(str, pad);
g_string_append(str, pad_full);
g_free(pad_full);
}
}