fix various trivial null derefs
authorMike Blumenkrantz <zmike@samsung.com>
Fri, 18 Oct 2019 17:30:10 +0000 (13:30 -0400)
committerWonki Kim <wonki_.kim@samsung.com>
Mon, 11 Nov 2019 02:18:26 +0000 (11:18 +0900)
Summary:
CIDs 1401081, 1401044, 1400983, 1400960, 1400927, 1400799, 1396946, 1396944,
     1383851, 1383847, 1382211, 1379921, 1379921

Reviewers: cedric

Reviewed By: cedric

Subscribers: #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D10452

src/bin/edje/edje_cc_script.c
src/bin/elementary/test_genlist.c
src/examples/elementary/performance/graphical.c
src/examples/elementary/performance/performance.c
src/lib/ecore/efl_loop_handler.c
src/lib/ephysics/ephysics_body.cpp
src/tests/eet/eet_test_common.c
src/tests/eina/eina_test_matrixsparse.c
src/tests/evas/evas_test_mesh.c

index 2e52ac1..1c972ed 100644 (file)
@@ -187,6 +187,7 @@ code_parse_internal(Code *code)
                   if (tmp->str) free(tmp->str);
                   free(tmp);
                }
+             if (!sym) break;
              if ((begin - 1) > body)
                {
                   sym->body = mem_alloc(sizeof(char) * (begin - body - 1));
index c3f4d95..749d04f 100644 (file)
@@ -5531,9 +5531,7 @@ test_genlist_show_item(void *data,
    g_data->gl = gl;
    g_data->itc1 = api->itc1;
 
-   if (g_data)
-     max = g_data->max_items;
-   else max = 20000;
+   max = g_data->max_items;
    for (i = 0; i <= max; i++)
        elm_genlist_item_append(gl, api->itc1, (void*)(uintptr_t)i, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
 
index c3a8768..d68d865 100644 (file)
@@ -509,6 +509,11 @@ _xml_attr_data(void *data EINA_UNUSED, const char *key, const char *value)
              globalGraphical.model_path = strdup(value);/*Don't forget update UI*/
              tmp = strdup(globalGraphical.model_path);
              a = strrchr(tmp,'.');
+             if (!a)
+               {
+                  free(tmp);
+                  return EINA_FALSE;
+               }
              format = malloc(sizeof (char) * (strlen(a) - 1));
              for (i = 0; i <= (int)strlen(a) - 1; i++)
                format[i] = a[i + 1];
index 7508a93..75f330c 100644 (file)
@@ -516,6 +516,11 @@ _load_mesh(void *data EINA_UNUSED, Evas_Object *obj, void *event_info)
         /*Get extension of file*/
         tmp = strdup(event_info);
         a = strrchr(tmp,'.');
+        if (!a)
+          {
+             free(tmp);
+             return;
+          }
         format = malloc(sizeof (char) * (strlen(a) - 1));
         for (i = 0; i <= (int)strlen(a) - 1; i++)
           format[i] = a[i + 1];
index 3bed513..4c1034e 100644 (file)
@@ -113,7 +113,7 @@ _handler_reset(Eo *obj, Efl_Loop_Handler_Data *pd)
 
         if (pd->handler_fd)
           _handler_active_update(obj, pd);
-        else
+        else if (pd->loop_data)
           {
              pd->handler_fd = _ecore_main_fd_handler_add
                (pd->loop, pd->loop_data, obj, pd->fd, _handler_flags_get(pd),
@@ -122,7 +122,7 @@ _handler_reset(Eo *obj, Efl_Loop_Handler_Data *pd)
              if (pd->handler_fd) _handler_active_update(obj, pd);
           }
      }
-   else if (pd->win32)
+   else if (pd->win32 && pd->loop_data)
      {
         pd->handler_win32 = _ecore_main_win32_handler_add
           (pd->loop, pd->loop_data, obj, pd->win32, _cb_handler_win32, obj);
index 20b5804..02c7e8d 100644 (file)
@@ -274,6 +274,7 @@ _ephysics_body_soft_body_slice_new(EPhysics_Body *body, double delta, double max
    faces = body->soft_body->m_faces;
 
    slice->index = index;
+   if (!faces.size()) return slice;
    slice->p[0].x = _ephysics_body_soft_body_slice_calc(
       faces[slice->index].m_n[0]->m_x.x(), delta, max);
    slice->p[0].y = 1 - _ephysics_body_soft_body_slice_calc(
index dba9ab1..b9011c7 100644 (file)
@@ -70,8 +70,7 @@ func7(EINA_UNUSED const Eina_Hash *hash,
    val = data;
    if (!val)
      *res = 1;
-
-   if (*val != 7)
+   else if (*val != 7)
      *res = 1;
 
    return EINA_TRUE;
index c1aba54..5c8b548 100644 (file)
@@ -208,6 +208,7 @@ EFL_START_TEST(eina_test_simple)
    fail_if(test1 != NULL);
 
    test1 = eina_matrixsparse_data_idx_get(matrix, 5, 3);
+   fail_if(!test1);
    fail_if(*test1 != data[5][3]);
 
    r = eina_matrixsparse_column_idx_clear(matrix, 3);
index d5777ed..95138e2 100644 (file)
@@ -92,6 +92,7 @@ return_zero_frame(Evas_Canvas3D_Mesh_Data *pd)
    Eina_List *l;
    Evas_Canvas3D_Mesh_Frame *f;
 
+   if (!pd) return NULL;
    EINA_LIST_FOREACH(pd->frames, l, f)
      {
         if (f->frame == 0)