GraphicsMagick: MAT: FixLogical(): Pass 'ldblk' as size_t.
GraphicsMagick Commits <[email protected]>
| Newsgroups | gmane.comp.video.graphicsmagick.cvs |
|---|---|
| Message-ID | <mailman.45359.1640627398.1346.graphicsmagick-commit@lists.sourceforge.net> |
changeset 4e25d7adb1e3 in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=4e25d7adb1e3
summary: MAT: FixLogical(): Pass 'ldblk' as size_t.
diffstat:
ChangeLog | 1 +
coders/mat.c | 42 +++++++++++++++++++++++-------------------
www/Changelog.html | 3 ++-
3 files changed, 26 insertions(+), 20 deletions(-)
diffs (105 lines):
diff -r 7f4d2d192524 -r 4e25d7adb1e3 ChangeLog
--- a/ChangeLog Mon Dec 27 09:57:46 2021 -0600
+++ b/ChangeLog Mon Dec 27 11:49:43 2021 -0600
@@ -3,6 +3,7 @@
* coders/mat.c (ReadMATImage): Change 'ldblk' to size_t and
check related calculations for overflow and to avoid possible
negative seek offsets.
+ (FixLogical): Pass 'ldblk' as size_t.
2021-12-25 Bob Friesenhahn <[email protected]>
diff -r 7f4d2d192524 -r 4e25d7adb1e3 coders/mat.c
--- a/coders/mat.c Mon Dec 27 09:57:46 2021 -0600
+++ b/coders/mat.c Mon Dec 27 11:49:43 2021 -0600
@@ -272,8 +272,11 @@
-static void FixSignedValues(PixelPacket *q, int y)
+static void FixSignedValues(PixelPacket *q, magick_uint32_t y)
{
+ if (y == 0)
+ return;
+
while(y-->0)
{
/* Please note that negative values will overflow
@@ -288,26 +291,28 @@
/** Fix whole row of logical/binary data. It means pack it. */
-static void FixLogical(unsigned char *Buff,int ldblk)
+static void FixLogical(unsigned char *Buff,size_t ldblk)
{
-unsigned char mask=128;
-unsigned char *BuffL = Buff;
-unsigned char val = 0;
+ unsigned char mask=128;
+ unsigned char *BuffL = Buff;
+ unsigned char val = 0;
+
+ if (ldblk == 0)
+ return;
while(ldblk-->0)
- {
- if(*Buff++ != 0)
- val |= mask;
+ {
+ if(*Buff++ != 0)
+ val |= mask;
- mask >>= 1;
- if(mask==0)
- {
- *BuffL++ = val;
- val = 0;
- mask = 128;
+ mask >>= 1;
+ if(mask==0)
+ {
+ *BuffL++ = val;
+ val = 0;
+ mask = 128;
+ }
}
-
- }
*BuffL = val;
}
@@ -896,7 +901,7 @@
ThrowMATReaderException(BlobError,UnableToObtainOffset,image);
}
if(SeekBlob(image,filepos,SEEK_SET) != filepos) break;
- /* printf("pos=%X\n",TellBlob(image)); */
+ /* printf("pos=%lX\n",(long) TellBlob(image)); */
MATLAB_HDR.DataType = ReadBlobXXXLong(image);
if(EOFBlob(image)) break;
@@ -1134,10 +1139,9 @@
}
/* ----- Load raster data ----- */
- BImgBuff = MagickAllocateResourceLimitedArray(unsigned char *,ldblk,sizeof(double)); /* Ldblk was set in the check phase */
+ BImgBuff = MagickAllocateResourceLimitedClearedArray(unsigned char *,ldblk,sizeof(double)); /* Ldblk was set in the check phase */
if (BImgBuff == NULL)
goto NoMemory;
- (void) memset(BImgBuff,0,ldblk*sizeof(double));
if (CellType==miDOUBLE) /* Find Min and Max Values for floats */
{
diff -r 7f4d2d192524 -r 4e25d7adb1e3 www/Changelog.html
--- a/www/Changelog.html Mon Dec 27 09:57:46 2021 -0600
+++ b/www/Changelog.html Mon Dec 27 11:49:43 2021 -0600
@@ -39,7 +39,8 @@
<blockquote>
* coders/mat.c (ReadMATImage): Change 'ldblk' to size_t and
check related calculations for overflow and to avoid possible
-negative seek offsets.</blockquote>
+negative seek offsets.
+(FixLogical): Pass 'ldblk' as size_t.</blockquote>
<p>2021-12-25 Bob Friesenhahn <<a class="reference external" href="mailto:bfriesen%40simple.dallas.tx.us">bfriesen<span>@</span>simple<span>.</span>dallas<span>.</span>tx<span>.</span>us</a>></p>
<blockquote>
<p>* magick/profile.c (AppendImageProfile): Deprecate this function