← Commit list

9b2a50efe

Denys Vlasenko
Denys Vlasenko
2026-02-06
SUCCESS Duration: 160s

Subject

*: use xasprintf_inplace() in more places

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0
gcc -Wp,-MD,applets/.usage.d -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer      -Iinclude -Iinclude -o applets/usage applets/usage.c

Build Log

(log yok)

Commit Diff GitHub →

editors/vi.c+9 -7
@@ -2682,19 +2682,23 @@ static void setops(char *args, int flg_no)
# if ENABLE_FEATURE_VI_COLON_EXPAND
static char *expand_args(char *args)
{
- char *s, *t;
+ char *s;
const char *replace;
args = xstrdup(args);
for (s = args; *s; s++) {
+ unsigned n;
+
if (*s == '%') {
replace = current_filename;
} else if (*s == '#') {
replace = alt_filename;
} else {
if (*s == '\\' && s[1] != '\0') {
- for (t = s++; *t; t++)
+ char *t;
+ for (t = s; *t; t++)
*t = t[1];
+ s++;
}
continue;
}
@@ -2705,11 +2709,9 @@ static char *expand_args(char *args)
return NULL;
}
- *s = '\0';
- t = xasprintf("%s%s%s", args, replace, s+1);
- s = t + (s - args) + strlen(replace);
- free(args);
- args = t;
+ n = (s - args);
+ xasprintf_inplace(args, "%.*s%s%s", n, args, replace, s+1);
+ s = args + n + strlen(replace);
}
return args;
}
miscutils/less.c+7 -7
@@ -839,13 +839,13 @@ static void print_found(const char *line)
goto start;
while (match_status == 0) {
- char *new = xasprintf("%s%.*s"HIGHLIGHT"%.*s"NORMAL,
- growline ? growline : "",
- (int)match_structs.rm_so, str,
- (int)(match_structs.rm_eo - match_structs.rm_so),
- str + match_structs.rm_so);
- free(growline);
- growline = new;
+ xasprintf_inplace(growline,
+ "%s%.*s"HIGHLIGHT"%.*s"NORMAL,
+ growline ? growline : "",
+ (int)match_structs.rm_so,
+ str,
+ (int)(match_structs.rm_eo - match_structs.rm_so),
+ str + match_structs.rm_so);
str += match_structs.rm_eo;
line += match_structs.rm_eo;
eflags = REG_NOTBOL;
shell/hush.c+1 -4
@@ -2941,12 +2941,9 @@ static void i_prepend_to_alias_buffer(struct in_str *i, char *prepend, char ch)
* a
* ^^^ runs "echo A: c"
*/
- char *old = i->albuf;
//bb_error_msg("before'%s' p'%s'", i->albuf, i->p);
- i->albuf = xasprintf("%s%c%s", prepend, ch, i->p);
- i->p = i->albuf;
+ i->p = xasprintf_inplace(i->albuf, "%s%c%s", prepend, ch, i->p);
//bb_error_msg("after'%s' p'%s'", i->albuf, i->p);
- free(old);
return;
}
i->saved_ibuf = i->p;