From 8723e4bcd840478cecfd29891e792edb499cd0e9 Mon Sep 17 00:00:00 2001 From: cristy Date: Thu, 1 Sep 2011 13:11:19 +0000 Subject: [PATCH] --- MagickCore/string.c | 42 ++++++++++++++++++++++++++++++++++++++++++ MagickCore/string_.h | 1 + coders/jpeg.c | 6 +++--- coders/pict.c | 4 ++-- coders/png.c | 2 +- coders/ps.c | 2 +- coders/psd.c | 2 +- 7 files changed, 51 insertions(+), 8 deletions(-) diff --git a/MagickCore/string.c b/MagickCore/string.c index 4e1504fd8..fc4dfc5a7 100644 --- a/MagickCore/string.c +++ b/MagickCore/string.c @@ -182,6 +182,48 @@ MagickExport StringInfo *AcquireStringInfo(const size_t length) % % % % % % +% B l o b T o S t r i n g I n f o % +% % +% % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% BlobToStringInfo() returns the contents of a blob as a string. +% +% The format of the BlobToStringInfo method is: +% +% StringInfo *BlobToStringInfo(const void *blob,const size_t length) +% +% A description of each parameter follows: +% +% o blob: the blob. +% +% o length: the length of the blob. +% +*/ +MagickExport StringInfo *BlobToStringInfo(const void *blob,const size_t length) +{ + StringInfo + *string_info; + + string_info=AcquireStringInfo(0); + string_info->datum=(unsigned char *) AcquireQuantumMemory(length, + sizeof(*string_info->datum)); + if (string_info->datum == (unsigned char *) NULL) + { + string_info=DestroyStringInfo(string_info); + return((StringInfo *) NULL); + } + if (blob != (const void *) NULL) + (void) memcpy(string_info->datum,blob,length); + return(string_info); +} + +/* +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% % +% % % C l o n e S t r i n g % % % % % diff --git a/MagickCore/string_.h b/MagickCore/string_.h index 96f6c0b4c..fd91415d8 100644 --- a/MagickCore/string_.h +++ b/MagickCore/string_.h @@ -79,6 +79,7 @@ extern MagickExport ssize_t extern MagickExport StringInfo *AcquireStringInfo(const size_t), + *BlobToStringInfo(const void *,const size_t), *CloneStringInfo(const StringInfo *), *ConfigureFileToStringInfo(const char *), *DestroyStringInfo(StringInfo *), diff --git a/coders/jpeg.c b/coders/jpeg.c index 69f7d1772..68a96e4b7 100644 --- a/coders/jpeg.c +++ b/coders/jpeg.c @@ -445,7 +445,7 @@ static boolean ReadICCProfile(j_decompress_ptr jpeg_info) length-=14; error_manager=(ErrorManager *) jpeg_info->client_data; image=error_manager->image; - profile=AcquireStringInfo(length); + profile=BlobToStringInfo((const void *) NULL,length); if (profile == (StringInfo *) NULL) ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed", image->filename); @@ -541,7 +541,7 @@ static boolean ReadIPTCProfile(j_decompress_ptr jpeg_info) return(MagickTrue); error_manager=(ErrorManager *) jpeg_info->client_data; image=error_manager->image; - profile=AcquireStringInfo(length); + profile=BlobToStringInfo((const void *) NULL,length); if (profile == (StringInfo *) NULL) ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed", image->filename); @@ -612,7 +612,7 @@ static boolean ReadProfile(j_decompress_ptr jpeg_info) (void) FormatLocaleString(name,MaxTextExtent,"APP%d",marker); error_manager=(ErrorManager *) jpeg_info->client_data; image=error_manager->image; - profile=AcquireStringInfo(length); + profile=BlobToStringInfo((const void *) NULL,length); if (profile == (StringInfo *) NULL) ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed", image->filename); diff --git a/coders/pict.c b/coders/pict.c index e851b6ace..5212776f9 100644 --- a/coders/pict.c +++ b/coders/pict.c @@ -1273,7 +1273,7 @@ static Image *ReadPICTImage(const ImageInfo *image_info, { if (length == 0) break; - profile=AcquireStringInfo(length); + profile=BlobToStringInfo((const void *) NULL,length); SetStringInfoDatum(profile,info); status=SetImageProfile(image,"icc",profile); profile=DestroyStringInfo(profile); @@ -1286,7 +1286,7 @@ static Image *ReadPICTImage(const ImageInfo *image_info, { if (length == 0) break; - profile=AcquireStringInfo(length); + profile=BlobToStringInfo((const void *) NULL,length); SetStringInfoDatum(profile,info); status=SetImageProfile(image,"iptc",profile); if (status == MagickFalse) diff --git a/coders/png.c b/coders/png.c index 91c519441..686fc7773 100644 --- a/coders/png.c +++ b/coders/png.c @@ -1849,7 +1849,7 @@ Magick_png_read_raw_profile(Image *image, const ImageInfo *image_info, return(MagickFalse); } - profile=AcquireStringInfo(length); + profile=BlobToStringInfo((const void *) NULL,length); if (profile == (StringInfo *) NULL) { diff --git a/coders/ps.c b/coders/ps.c index 41e9d329e..a0d6d326f 100644 --- a/coders/ps.c +++ b/coders/ps.c @@ -557,7 +557,7 @@ static Image *ReadPSImage(const ImageInfo *image_info,ExceptionInfo *exception) if (count != 1) continue; length=extent; - profile=AcquireStringInfo(length); + profile=BlobToStringInfo((const void *) NULL,length); p=GetStringInfoDatum(profile); for (i=0; i < (ssize_t) length; i++) *p++=(unsigned char) ProfileInteger(image,hex_digits); diff --git a/coders/psd.c b/coders/psd.c index a0ad522e5..5c8ad2206 100644 --- a/coders/psd.c +++ b/coders/psd.c @@ -424,7 +424,7 @@ static MagickBooleanType ParseImageResourceBlocks(Image *image, if (length < 16) return(MagickFalse); - profile=AcquireStringInfo(length); + profile=BlobToStringInfo((const void *) NULL,length); SetStringInfoDatum(profile,blocks); (void) SetImageProfile(image,"8bim",profile); profile=DestroyStringInfo(profile); -- 2.40.0