Avoid strcat calls with NULL argument

This commit is contained in:
pancake 2022-09-20 12:14:34 +02:00 committed by pancake
parent 849b7e4018
commit 416086a859

View File

@ -844,9 +844,11 @@ static int cmd_alias(void *data, const char *input) {
if (v) {
if (v->is_data) {
char *v_str = r_cmd_alias_val_strdup (v);
r_cons_strcat (v_str);
r_cons_newline ();
free (v_str);
if (v_str) {
r_cons_strcat (v_str);
r_cons_newline ();
free (v_str);
}
} else if (q) {
char *out = r_str_newf ("%s %s", (char *)v->data, q + 1);
r_core_cmd0 (core, out);
@ -5261,8 +5263,10 @@ R_API int r_core_cmd_foreach(RCore *core, const char *cmd, char *each) {
}
}
char *s = r_strbuf_drain (sb);
r_cons_strcat (s);
free (s);
if (s) {
r_cons_strcat (s);
free (s);
}
core->cons->context->grep = grep;
}
goto out_finish;
@ -5473,8 +5477,10 @@ R_API int r_core_cmd_foreach(RCore *core, const char *cmd, char *each) {
tmp = r_cons_get_buffer ();
buf = tmp? strdup (tmp): NULL;
r_cons_pop ();
r_cons_strcat (buf);
free (buf);
if (buf) {
r_cons_strcat (buf);
free (buf);
}
if (!foreach_newline (core)) {
break;
}