]> granicus.if.org Git - imagemagick/blobdiff - MagickCore/blob.c
...
[imagemagick] / MagickCore / blob.c
index 1c6d98b3c2a3d0cb55fbc228385dcc7e1bd79841..477527d05914c0c50204d65e49a86dc89dced3be 100644 (file)
@@ -212,11 +212,12 @@ static int
 %
 */
 MagickExport CustomStreamInfo *AcquireCustomStreamInfo(
-  ExceptionInfo *exception)
+  ExceptionInfo *magick_unused(exception))
 {
   CustomStreamInfo
     *custom_stream;
 
+  magick_unreferenced(exception);
   custom_stream=(CustomStreamInfo *) AcquireMagickMemory(
     sizeof(*custom_stream));
   if (custom_stream == (CustomStreamInfo *) NULL)
@@ -1517,7 +1518,22 @@ MagickExport MagickSizeType GetBlobSize(const Image *image)
       break;
     }
     case CustomStream:
+    {
+      if ((image->blob->custom_stream->teller != (CustomStreamTeller) NULL) &&
+          (image->blob->custom_stream->seeker != (CustomStreamSeeker) NULL))
+        {
+          MagickOffsetType
+            offset;
+
+          offset=image->blob->custom_stream->teller(
+            image->blob->custom_stream->data);
+          extent=image->blob->custom_stream->seeker(0,SEEK_END,
+            image->blob->custom_stream->data);
+          image->blob->custom_stream->seeker(offset,SEEK_SET,
+            image->blob->custom_stream->data);
+        }
       break;
+    }
   }
   return(extent);
 }
@@ -3365,8 +3381,9 @@ MagickExport ssize_t ReadBlob(Image *image,const size_t length,void *data)
     }
     case CustomStream:
     {
-      count=image->blob->custom_stream->reader(q,length,
-        image->blob->custom_stream->data);
+      if (image->blob->custom_stream->reader != (CustomStreamHandler) NULL)
+        count=image->blob->custom_stream->reader(q,length,
+          image->blob->custom_stream->data);
       break;
     }
   }
@@ -4259,6 +4276,7 @@ MagickExport char *ReadBlobString(Image *image,char *string)
       {
         if (i == 0)
           return((char *) NULL);
+        string[i]='\0';
         break;
       }
     string[i]=(char) (*p);
@@ -5167,11 +5185,11 @@ MagickExport ssize_t WriteBlob(Image *image,const size_t length,
 
   assert(image != (Image *) NULL);
   assert(image->signature == MagickCoreSignature);
-  assert(data != (const void *) NULL);
   assert(image->blob != (BlobInfo *) NULL);
   assert(image->blob->type != UndefinedStream);
   if (length == 0)
     return(0);
+  assert(data != (const void *) NULL);
   count=0;
   p=(const unsigned char *) data;
   switch (image->blob->type)
@@ -5312,8 +5330,9 @@ MagickExport ssize_t WriteBlob(Image *image,const size_t length,
     }
     case CustomStream:
     {
-      count=image->blob->custom_stream->writer((const unsigned char *) data,
-        length,image->blob->custom_stream->data);
+      if (image->blob->custom_stream->writer != (CustomStreamHandler) NULL)
+        count=image->blob->custom_stream->writer((const unsigned char *) data,
+          length,image->blob->custom_stream->data);
       break;
     }
   }