Cleanup: use early return, avoids passing uninitialized argument

An uninitialized `msg` string could be passed into ED_area_status_text
however the argument wasn't used when the area was null.

Even though this isn't a bug it relies on the `area` check in the
implementation to ignore the uninitialized argument.

Simplify logic by returning early when area is null.
This commit is contained in:
Campbell Barton
2024-04-23 15:06:50 +10:00
parent 2a2579e69c
commit e082049dff

View File

@@ -621,17 +621,18 @@ static int sequencer_slip_exec(bContext *C, wmOperator *op)
static void sequencer_slip_update_header(Scene *scene, ScrArea *area, SlipData *data, int offset)
{
char msg[UI_MAX_DRAW_STR];
if (area == nullptr) {
return;
}
if (area) {
if (hasNumInput(&data->num_input)) {
char num_str[NUM_STR_REP_LEN];
outputNumInput(&data->num_input, num_str, &scene->unit);
SNPRINTF(msg, IFACE_("Slip offset: %s"), num_str);
}
else {
SNPRINTF(msg, IFACE_("Slip offset: %d"), offset);
}
char msg[UI_MAX_DRAW_STR];
if (hasNumInput(&data->num_input)) {
char num_str[NUM_STR_REP_LEN];
outputNumInput(&data->num_input, num_str, &scene->unit);
SNPRINTF(msg, IFACE_("Slip offset: %s"), num_str);
}
else {
SNPRINTF(msg, IFACE_("Slip offset: %d"), offset);
}
ED_area_status_text(area, msg);