]> granicus.if.org Git - imagemagick/blobdiff - MagickCore/xml-tree.c
(no commit message)
[imagemagick] / MagickCore / xml-tree.c
index 21bb0ae0db0782d690f933db21cf8648ecb94ca2..e3c8a82acfa1f231bce6c85cc2ed4ad436a3c00d 100644 (file)
@@ -1519,7 +1519,8 @@ static char *ParseEntities(char *xml,char **entities,int state)
                   xml=p+offset;
                   entity=strchr(xml,';');
                 }
-              (void) CopyMagickMemory(xml+length,entity+1,strlen(entity));
+              if (entity != (char *) NULL)
+                (void) CopyMagickMemory(xml+length,entity+1,strlen(entity));
               (void) strncpy(xml,entities[i],length);
             }
         }
@@ -1562,7 +1563,7 @@ static void ParseCharacterContent(XMLTreeRoot *root,char *xml,
     return;
   xml[length]='\0';
   xml=ParseEntities(xml,root->entities,state);
-  if (*xml_info->content != '\0')
+  if ((xml_info->content != (char *) NULL) && (*xml_info->content != '\0'))
     {
       (void) ConcatenateString(&xml_info->content,xml);
       xml=DestroyString(xml);
@@ -1683,7 +1684,7 @@ static void ParseProcessingInstructions(XMLTreeRoot *root,char *xml,
     ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
   root->processing_instructions[i][j+2]=(char *) ResizeQuantumMemory(
     root->processing_instructions[i][j+1],(size_t) (j+1),
-    sizeof(**root->processing_instructions));
+    sizeof(*root->processing_instructions));
   if (root->processing_instructions[i][j+2] == (char *) NULL)
     ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
   (void) CopyMagickString(root->processing_instructions[i][j+2]+j-1,
@@ -1796,6 +1797,7 @@ static MagickBooleanType ParseInternalDoctype(XMLTreeRoot *root,char *xml,
             *xml='\0';
             i=0;
             while ((root->attributes[i] != (char **) NULL) &&
+                   (n != (char *) NULL) &&
                    (strcmp(n,root->attributes[i][0]) != 0))
               i++;
             while ((*(n=xml+strspn(xml+1,XMLWhitespace)+1) != '\0') &&
@@ -1921,7 +1923,8 @@ static void ParseOpenTag(XMLTreeRoot *root,char *tag,char **attributes)
     xml_info->tag=ConstantString(tag);
   else
     xml_info=AddChildToXMLTree(xml_info,tag,strlen(xml_info->content));
-  xml_info->attributes=attributes;
+  if (xml_info != (XMLTreeInfo *) NULL)
+    xml_info->attributes=attributes;
   root->node=xml_info;
 }
 
@@ -2494,7 +2497,7 @@ MagickPrivate XMLTreeInfo *SetXMLTreeAttribute(XMLTreeInfo *xml_info,
   j-=2;
   (void) CopyMagickMemory(xml_info->attributes[j+1]+(i/2),
     xml_info->attributes[j+1]+(i/2)+1,(size_t) (((j+2)/2)-(i/2))*
-    sizeof(*xml_info->attributes));
+    sizeof(**xml_info->attributes));
   return(xml_info);
 }
 \f