]> granicus.if.org Git - imagemagick/blobdiff - MagickCore/blob.c
...
[imagemagick] / MagickCore / blob.c
index 6050037587acf2c4f2f5eef6a71d7f87b19261dd..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);
@@ -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;
     }
   }