diff options
author | hj kim <backto.kim@samsung.com> | 2020-12-02 13:27:00 +0900 |
---|---|---|
committer | hj kim <backto.kim@samsung.com> | 2020-12-02 13:27:37 +0900 |
commit | 332002e6f4d7ce48ea4eeb55b59d84c64ad79f0b (patch) | |
tree | c52e09b3325e6f6c777fd247a9b97f52bab5e8f3 /coders/ps2.c | |
parent | f5839121f0b6145e732bdb0b3e8196e48fbe3745 (diff) | |
download | GraphicsMagick-332002e6f4d7ce48ea4eeb55b59d84c64ad79f0b.tar.gz GraphicsMagick-332002e6f4d7ce48ea4eeb55b59d84c64ad79f0b.tar.bz2 GraphicsMagick-332002e6f4d7ce48ea4eeb55b59d84c64ad79f0b.zip |
Imported Upstream version 1.3.35upstream/1.3.35
Change-Id: I4f31a0b17e1ca89907f274d952d43e60ffa4c769
Diffstat (limited to 'coders/ps2.c')
-rw-r--r-- | coders/ps2.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/coders/ps2.c b/coders/ps2.c index fe2ed80..9b7e0dd 100644 --- a/coders/ps2.c +++ b/coders/ps2.c @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003 - 2019 GraphicsMagick Group +% Copyright (C) 2003 - 2020 GraphicsMagick Group % Copyright (C) 2002 ImageMagick Studio % Copyright 1991-1999 E. I. du Pont de Nemours and Company % @@ -511,7 +511,10 @@ static unsigned int WritePS2Image(const ImageInfo *image_info,Image *image) /* Output Postscript header. */ - if (LocaleCompare(image_info->magick,"PS2") == 0) + #if defined(HAVE_CTIME_R) + char time_buf[26]; +#endif /* defined(HAVE_CTIME_R) */ + if (LocaleCompare(image_info->magick,"PS2") == 0) (void) strcpy(buffer,"%!PS-Adobe-3.0\n"); else (void) strcpy(buffer,"%!PS-Adobe-3.0 EPSF-3.0\n"); @@ -520,15 +523,18 @@ static unsigned int WritePS2Image(const ImageInfo *image_info,Image *image) FormatString(buffer,"%%%%Title: (%.1024s)\n",image->filename); (void) WriteBlobString(image,buffer); timer=time((time_t *) NULL); - (void) localtime(&timer); - (void) strlcpy(date,ctime(&timer),MaxTextExtent); +#if defined(HAVE_CTIME_R) + (void) strlcpy(date,ctime_r(&timer,time_buf),MaxTextExtent); +#else + (void) strlcpy(date,ctime(&timer),MaxTextExtent); /* Thread-unsafe version */ +#endif /* defined(HAVE_CTIME_R) */ date[strlen(date)-1]='\0'; FormatString(buffer,"%%%%CreationDate: (%.1024s)\n",date); (void) WriteBlobString(image,buffer); bounds.x1=geometry.x; bounds.y1=geometry.y; - bounds.x2=geometry.x+geometry.width; - bounds.y2=geometry.y+geometry.height+text_size; + bounds.x2=geometry.x+(size_t) geometry.width; + bounds.y2=geometry.y+(size_t) geometry.height+text_size; if (image_info->adjoin && (image->next != (Image *) NULL)) (void) strcpy(buffer,"%%BoundingBox: (atend)\n"); else @@ -757,10 +763,10 @@ static unsigned int WritePS2Image(const ImageInfo *image_info,Image *image) bounds.x1=geometry.x; if (geometry.y < bounds.y1) bounds.y1=geometry.y; - if ((geometry.x+(long) geometry.width-1) > bounds.x2) - bounds.x2=geometry.x+geometry.width-1; - if ((geometry.y+(long) (geometry.height+text_size)-1) > bounds.y2) - bounds.y2=geometry.y+(geometry.height+text_size)-1; + if ((geometry.x+(size_t) geometry.width-1) > bounds.x2) + bounds.x2=geometry.x+(size_t) geometry.width-1; + if ((geometry.y+((size_t) geometry.height+text_size)-1) > bounds.y2) + bounds.y2=geometry.y+((size_t) geometry.height+text_size)-1; attribute=GetImageAttribute(image,"label"); if (attribute != (const ImageAttribute *) NULL) (void) WriteBlobString(image,"%%PageResources: font Times-Roman\n"); @@ -960,8 +966,8 @@ static unsigned int WritePS2Image(const ImageInfo *image_info,Image *image) /* Allocate pixel array. */ - length=(image->colorspace == CMYKColorspace ? 4 : 3)* - number_pixels; + length=MagickArraySize(image->colorspace == CMYKColorspace ? 4 : 3, + number_pixels); pixels=MagickAllocateMemory(unsigned char *,length); if (pixels == (unsigned char *) NULL) ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,image); |