Prevent more Coverity warnings

This commit is contained in:
twinaphex 2018-02-04 19:45:47 +01:00
parent 3d0e768e71
commit df1c131520

View File

@ -585,12 +585,15 @@ static void mui_render_messagebox(mui_handle_t *mui,
int x, y, line_height, longest = 0, longest_width = 0; int x, y, line_height, longest = 0, longest_width = 0;
unsigned width = video_info->width; unsigned width = video_info->width;
unsigned height = video_info->height; unsigned height = video_info->height;
struct string_list *list = (struct string_list*) struct string_list *list = NULL;
if (!mui || !mui->font)
goto end;
list = (struct string_list*)
string_split(message, "\n"); string_split(message, "\n");
if (!list) if (!list || list->elems == 0)
return;
if (list->elems == 0)
goto end; goto end;
line_height = mui->font->size * 1.2; line_height = mui->font->size * 1.2;
@ -610,16 +613,18 @@ static void mui_render_messagebox(mui_handle_t *mui,
if (len > longest) if (len > longest)
{ {
longest = len; longest = len;
longest_width = font_driver_get_message_width(mui->font, msg, strlen(msg), 1); longest_width = font_driver_get_message_width(
mui->font, msg, strlen(msg), 1);
} }
} }
menu_display_set_alpha(body_bg_color, 1.0); menu_display_set_alpha(body_bg_color, 1.0);
menu_display_draw_quad( x - longest_width/2.0 - mui->margin*2.0, menu_display_draw_quad(
y - line_height/2.0 - mui->margin*2.0, x - longest_width / 2.0 - mui->margin * 2.0,
longest_width + mui->margin*4.0, y - line_height / 2.0 - mui->margin * 2.0,
line_height * list->size + mui->margin*4.0, longest_width + mui->margin * 4.0,
line_height * list->size + mui->margin * 4.0,
width, width,
height, height,
&body_bg_color[0]); &body_bg_color[0]);
@ -629,7 +634,8 @@ static void mui_render_messagebox(mui_handle_t *mui,
{ {
const char *msg = list->elems[i].data; const char *msg = list->elems[i].data;
if (msg) if (msg)
menu_display_draw_text(mui->font, msg, menu_display_draw_text(
mui->font, msg,
x - longest_width/2.0, x - longest_width/2.0,
y + i * line_height + mui->font->size / 3, y + i * line_height + mui->font->size / 3,
width, height, font_color, TEXT_ALIGN_LEFT, 1.0f, false, 0); width, height, font_color, TEXT_ALIGN_LEFT, 1.0f, false, 0);
@ -642,7 +648,8 @@ static void mui_render_messagebox(mui_handle_t *mui,
menu_event_get_osk_grid(), menu_event_get_osk_ptr()); menu_event_get_osk_grid(), menu_event_get_osk_ptr());
end: end:
string_list_free(list); if (list)
string_list_free(list);
} }
/* Used for the sublabels */ /* Used for the sublabels */