Coverity #1098277, #1098279, #1360822 fixed 72/18472/2
Dhruv Khattar [Tue, 16 Aug 2016 20:45:08 +0000 (01:45 +0530)]
Change-Id: Ic5f6fccad435eca7bd1ea2ed711a378dd9383323

scilab/modules/xml/sci_gateway/cpp/sci_percent_foo_i_XMLList.cpp
scilab/modules/xml/src/cpp/XMLMlistsManagement.cpp

index 835406e..93ba0c5 100644 (file)
@@ -97,7 +97,10 @@ int sci_percent_foo_i_XMLList(char *fname, void* pvApiCtx)
 
     prefix = os_strdup(fname);
     underscore = strchr(prefix, '_');
-    *underscore = '\0';
+    if (underscore)
+    {
+        *underscore = '\0';
+    }
     format = (char *)MALLOC(sizeof(char) * (strlen(prefix) + strlen("_xmlFormat") + 1));
     sprintf(format, "%s_xmlFormat", prefix);
     free(prefix);
index ca35f9c..ee2382c 100644 (file)
@@ -48,37 +48,32 @@ int createXMLObjectAtPos(int type, int pos, int id, void* pvApiCtx)
     switch (type)
     {
         case XMLDOCUMENT:
-            ;
             fields = _XMLDoc;
             break;
         case XMLELEMENT:
-            ;
             fields = _XMLElem;
             break;
         case XMLATTRIBUTE:
-            ;
             fields = _XMLAttr;
             break;
         case XMLNAMESPACE:
-            ;
             fields = _XMLNs;
             break;
         case XMLLIST:
-            ;
             fields = _XMLList;
             break;
         case XMLNOTHANDLED:
-            ;
             fields = _XMLNotHandled;
             break;
         case XMLSET:
-            ;
             fields = _XMLSet;
             break;
         case XMLVALID:
-            ;
             fields = _XMLValid;
             break;
+        default:
+            Scierror(999, _("Unknown tag.\n"));
+            return 0;
     }
 
     err = createMList(pvApiCtx, pos, 2, &mlistaddr);
@@ -121,37 +116,32 @@ int createXMLObjectAtPosInList(int *list, int stackPos, int type, int pos, int i
     switch (type)
     {
         case XMLDOCUMENT:
-            ;
             fields = _XMLDoc;
             break;
         case XMLELEMENT:
-            ;
             fields = _XMLElem;
             break;
         case XMLATTRIBUTE:
-            ;
             fields = _XMLAttr;
             break;
         case XMLNAMESPACE:
-            ;
             fields = _XMLNs;
             break;
         case XMLLIST:
-            ;
             fields = _XMLList;
             break;
         case XMLNOTHANDLED:
-            ;
             fields = _XMLNotHandled;
             break;
         case XMLSET:
-            ;
             fields = _XMLSet;
             break;
         case XMLVALID:
-            ;
             fields = _XMLValid;
             break;
+        default:
+            Scierror(999, _("Unknown tag.\n"));
+            return 0;
     }
 
     err = createMatrixOfStringInList(pvApiCtx, stackPos, mlistaddr, 1, 1, 2, fields);