From df43c1f99b02deb5f1ac6030e72dffc53d011af5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 21 Jan 2016 21:27:54 +0100 Subject: [PATCH] Try to avoid crash in gfx_ctx_get_metrics --- gfx/video_context_driver.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/gfx/video_context_driver.c b/gfx/video_context_driver.c index 55c11ca351..a86cb03adf 100644 --- a/gfx/video_context_driver.c +++ b/gfx/video_context_driver.c @@ -182,16 +182,18 @@ bool gfx_ctx_set_video_mode( void gfx_ctx_translate_aspect(float *aspect, unsigned width, unsigned height) { - if (current_video_context->translate_aspect) - *aspect = current_video_context->translate_aspect(video_context_data, width, height); + if (!current_video_context || !current_video_context->translate_aspect) + return; + + *aspect = current_video_context->translate_aspect(video_context_data, width, height); } bool gfx_ctx_get_metrics(enum display_metric_types type, float *value) { - if (current_video_context->get_metrics) - return current_video_context->get_metrics(video_context_data, type, - value); - return false; + if (!current_video_context || !current_video_context->get_metrics) + return false; + return current_video_context->get_metrics(video_context_data, type, + value); } bool gfx_ctx_image_buffer_init(const video_info_t* info)