diff --git a/message_queue.c b/message_queue.c index 2097acb8d8..f7256884c5 100644 --- a/message_queue.c +++ b/message_queue.c @@ -55,14 +55,17 @@ msg_queue_t *msg_queue_new(size_t size) void msg_queue_free(msg_queue_t *queue) { - msg_queue_clear(queue); - free(queue->elems); + if (queue) + { + msg_queue_clear(queue); + free(queue->elems); + } free(queue); } void msg_queue_push(msg_queue_t *queue, const char *msg, unsigned prio, unsigned duration) { - if (queue->ptr >= queue->size) + if (!queue || queue->ptr >= queue->size) return; struct queue_elem *new_elem = (struct queue_elem*)calloc(1, sizeof(struct queue_elem)); @@ -91,6 +94,9 @@ void msg_queue_push(msg_queue_t *queue, const char *msg, unsigned prio, unsigned void msg_queue_clear(msg_queue_t *queue) { + if (!queue) + return; + size_t i; for (i = 1; i < queue->ptr; i++) { @@ -108,7 +114,7 @@ void msg_queue_clear(msg_queue_t *queue) const char *msg_queue_pull(msg_queue_t *queue) { - if (queue->ptr == 1) // Nothing in queue. :( + if (!queue || queue->ptr == 1) // Nothing in queue. return NULL; struct queue_elem *front = queue->elems[1]; diff --git a/settings_data.c b/settings_data.c index 999810bc36..86645e2441 100644 --- a/settings_data.c +++ b/settings_data.c @@ -615,9 +615,12 @@ static void general_change_handler(const void *data) g_settings.video.fullscreen_y = *setting->value.unsigned_integer; else if (!strcmp(setting->name, "video_refresh_rate")) { - driver_set_monitor_refresh_rate(*setting->value.fraction); - /* In case refresh rate update forced non-block video. */ - video_set_nonblock_state_func(false); + if (driver.video && driver.video_data) + { + driver_set_monitor_refresh_rate(*setting->value.fraction); + /* In case refresh rate update forced non-block video. */ + video_set_nonblock_state_func(false); + } } else if (!strcmp(setting->name, "video_aspect_ratio")) g_settings.video.aspect_ratio = *setting->value.fraction;