*/
MagickExport char *ReadBlobString(Image *image,char *string)
{
- register const unsigned char
- *p;
+ int
+ c;
register ssize_t
i;
- ssize_t
- count;
-
- unsigned char
- buffer[1];
-
assert(image != (Image *) NULL);
assert(image->signature == MagickCoreSignature);
for (i=0; i < (MagickPathExtent-1L); i++)
{
- p=(const unsigned char *) ReadBlobStream(image,1,buffer,&count);
- if (count != 1)
+ c=ReadBlobByte(image);
+ if (c == EOF)
{
if (i == 0)
return((char *) NULL);
- string[i]='\0';
break;
}
- string[i]=(char) (*p);
- if ((string[i] == '\r') || (string[i] == '\n'))
- break;
+ string[i]=c;
+ if (c == '\n')
+ {
+ if ((i > 0) && (string[i-1] == '\r'))
+ i--;
+ break;
+ }
}
- if (string[i] == '\r')
- (void) ReadBlobStream(image,1,buffer,&count);
string[i]='\0';
return(string);
}
}
/* convert sixel data into indexed pixel bytes and palette data */
-MagickBooleanType sixel_decode(unsigned char /* in */ *p, /* sixel bytes */
+MagickBooleanType sixel_decode(Image *image,
+ unsigned char /* in */ *p, /* sixel bytes */
unsigned char /* out */ **pixels, /* decoded pixels */
size_t /* out */ *pwidth, /* image width */
size_t /* out */ *pheight, /* image height */
unsigned char /* out */ **palette, /* ARGB palette */
- size_t /* out */ *ncolors /* palette size (<= 256) */)
+ size_t /* out */ *ncolors, /* palette size (<= 256) */
+ ExceptionInfo *exception)
{
int n, i, r, g, b, sixel_vertical_mask, c;
int posision_x, posision_y;
imsx = 2048;
imsy = 2048;
+ if (SetImageExtent(image,imsx,imsy,exception) == MagickFalse)
+ return(MagickFalse);
imbuf = (unsigned char *) AcquireQuantumMemory(imsx , imsy);
if (imbuf == NULL) {
if (imsx < attributed_ph || imsy < attributed_pv) {
dmsx = imsx > attributed_ph ? imsx : attributed_ph;
dmsy = imsy > attributed_pv ? imsy : attributed_pv;
+ if (SetImageExtent(image,dmsx,dmsy,exception) == MagickFalse)
+ break;
dmbuf = (unsigned char *) AcquireQuantumMemory(dmsx , dmsy);
if (dmbuf == (unsigned char *) NULL) {
imbuf = (unsigned char *) RelinquishMagickMemory(imbuf);
dmsx = nx;
dmsy = ny;
+ if (SetImageExtent(image,dmsx,dmsy,exception) == MagickFalse)
+ break;
dmbuf = (unsigned char *) AcquireQuantumMemory(dmsx , dmsy);
if (dmbuf == (unsigned char *) NULL) {
imbuf = (unsigned char *) RelinquishMagickMemory(imbuf);
if (imsx > max_x || imsy > max_y) {
dmsx = max_x;
dmsy = max_y;
+ if (SetImageExtent(image,dmsx,dmsy,exception) == MagickFalse)
+ {
+ imbuf = (unsigned char *) RelinquishMagickMemory(imbuf);
+ return (MagickFalse);
+ }
if ((dmbuf = (unsigned char *) AcquireQuantumMemory(dmsx , dmsy)) == NULL) {
imbuf = (unsigned char *) RelinquishMagickMemory(imbuf);
return (MagickFalse);
/*
Decode SIXEL
*/
- if (sixel_decode((unsigned char *) sixel_buffer,&sixel_pixels,&image->columns,&image->rows,&sixel_palette,&image->colors) == MagickFalse)
+ if (sixel_decode(image,(unsigned char *) sixel_buffer,&sixel_pixels,&image->columns,&image->rows,&sixel_palette,&image->colors,exception) == MagickFalse)
{
sixel_buffer=(char *) RelinquishMagickMemory(sixel_buffer);
ThrowReaderException(CorruptImageError,"CorruptImage");