keyrouter: Properly test for allocation failure 13/278213/1
authorSeunghun Lee <shiin.lee@samsung.com>
Wed, 8 Jun 2022 07:25:42 +0000 (16:25 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Mon, 18 Jul 2022 05:58:54 +0000 (14:58 +0900)
Instead of testing the return of the function just called, it was
testing something already checked earlier.

Change-Id: Ibaa7884360afaa195d843bc90588e3af85caf0d0

src/keyrouter/keyrouter_grab.c

index 5009985..6af0c85 100644 (file)
@@ -300,7 +300,7 @@ keyrouter_grab_create(void)
 
     /* FIXME: Who defined max keycode? */
     keyrouter_grab->hard_keys = calloc(KEYROUTER_MAX_KEYS, sizeof(struct ds_tizen_keyrouter_grabbed));
-    if (keyrouter_grab == NULL) {
+    if (keyrouter_grab->hard_keys == NULL) {
         ds_err("Failed to allocate memory.");
         free(keyrouter_grab);
         return NULL;