Eolian/Lexer: Fix coverity issues.
authorDaniel Zaoui <daniel.zaoui@samsung.com>
Fri, 18 Apr 2014 06:21:35 +0000 (09:21 +0300)
committerDaniel Zaoui <daniel.zaoui@samsung.com>
Fri, 18 Apr 2014 06:21:35 +0000 (09:21 +0300)
Fix CID 1203411
Fix CID 1203412

src/lib/eolian/eo_lexer.c
src/lib/eolian/eo_lexer.rl
src/lib/eolian/eolian_database.c
src/lib/eolian/eolian_database.h

index 2a29144..739fc0f 100644 (file)
@@ -4360,7 +4360,7 @@ _types_extract(const char *buf, int len)
                         if (depth < 0)
                           {
                              ERR("%s: Cannot reopen < after >", save_buf);
-                             return NULL;
+                             goto error;
                           }
                         depth++;
                         end_type = EINA_TRUE;
@@ -4371,12 +4371,12 @@ _types_extract(const char *buf, int len)
                         if (depth == 0)
                           {
                              ERR("%s: Too much >", save_buf);
-                             return NULL;
+                             goto error;
                           }
                         if (d == tmp_type)
                           {
                              ERR("%s: empty type inside <>", save_buf);
-                             return NULL;
+                             goto error;
                           }
                         if (depth > 0) depth *= -1;
                         depth++;
@@ -4400,9 +4400,14 @@ _types_extract(const char *buf, int len)
      }
    if (depth)
      {
-        types = NULL;
         ERR("%s: < and > are not well used.", save_buf);
+        goto error;
      }
+   goto success;
+error:
+   database_type_del(types);
+   types = NULL;
+success:
    free(tmp_type);
    return types;
 }
index a753300..b36b460 100644 (file)
@@ -1330,7 +1330,7 @@ _types_extract(const char *buf, int len)
                         if (depth < 0)
                           {
                              ERR("%s: Cannot reopen < after >", save_buf);
-                             return NULL;
+                             goto error;
                           }
                         depth++;
                         end_type = EINA_TRUE;
@@ -1341,12 +1341,12 @@ _types_extract(const char *buf, int len)
                         if (depth == 0)
                           {
                              ERR("%s: Too much >", save_buf);
-                             return NULL;
+                             goto error;
                           }
                         if (d == tmp_type)
                           {
                              ERR("%s: empty type inside <>", save_buf);
-                             return NULL;
+                             goto error;
                           }
                         if (depth > 0) depth *= -1;
                         depth++;
@@ -1370,9 +1370,14 @@ _types_extract(const char *buf, int len)
      }
    if (depth)
      {
-        types = NULL;
         ERR("%s: < and > are not well used.", save_buf);
+        goto error;
      }
+   goto success;
+error:
+   database_type_del(types);
+   types = NULL;
+success:
    free(tmp_type);
    return types;
 }
index 30ac8db..cb815fe 100644 (file)
@@ -108,16 +108,22 @@ _param_del(_Parameter_Desc *pdesc)
 {
    eina_stringshare_del(pdesc->name);
 
-   while (pdesc->type)
-     {
-        _Parameter_Type *type = (_Parameter_Type *) pdesc->type;
-        eina_stringshare_del(type->name);
-        pdesc->type = eina_inlist_remove(pdesc->type, EINA_INLIST_GET(type));
-     }
+   database_type_del(pdesc->type);
    eina_stringshare_del(pdesc->description);
    free(pdesc);
 }
 
+void
+database_type_del(Eolian_Type type)
+{
+   while (type)
+     {
+        _Parameter_Type *ptype = (_Parameter_Type *) type;
+        eina_stringshare_del(ptype->name);
+        type = eina_inlist_remove(type, EINA_INLIST_GET(ptype));
+     }
+}
+
 static void
 _fid_del(_Function_Id *fid)
 {
index 106ffea..82e9a3a 100644 (file)
@@ -88,6 +88,8 @@ Eolian_Function_Parameter database_method_parameter_add(Eolian_Function foo_id,
 
 Eolian_Type database_type_append(Eolian_Type types, const char *name, Eina_Bool own);
 
+void database_type_del(Eolian_Type type);
+
 void database_parameter_const_attribute_set(Eolian_Function_Parameter param_desc, Eina_Bool is_get, Eina_Bool is_const);
 
 void database_parameter_nonull_set(Eolian_Function_Parameter, Eina_Bool nonull);