[retro-gtk/core-fixes: 8/9] core: Check controller in retro_core_set_default_controller()



commit b935f182e00e13aa75e72b77a615e3cf950d8ae8
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Sun Feb 16 15:07:39 2020 +0100

    core: Check controller in retro_core_set_default_controller()
    
    The precondition should be checked to warn of wrong usages.

 retro-gtk/retro-core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/retro-gtk/retro-core.c b/retro-gtk/retro-core.c
index fadb290..55ce0fb 100644
--- a/retro-gtk/retro-core.c
+++ b/retro-gtk/retro-core.c
@@ -1624,11 +1624,12 @@ retro_core_set_default_controller (RetroCore           *self,
 
   g_return_if_fail (RETRO_IS_CORE (self));
   g_return_if_fail (controller_type < RETRO_CONTROLLER_TYPE_COUNT);
+  g_return_if_fail (controller == NULL || RETRO_IS_CONTROLLER (controller));
 
   if (self->default_controllers[controller_type])
     free_default_controller_info (self->default_controllers[controller_type]);
 
-  if (RETRO_IS_CONTROLLER (controller)) {
+  if (controller != NULL) {
     info = g_new0 (RetroCoreDefaultControllerInfo, 1);
 
     info->controller = g_object_ref (controller);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]