* VisualPng.C -- Shows a PNG image
*------------------------------------
*
- * Copyright 2000, Willem van Schaik.
+ * Copyright 2000,2017 Willem van Schaik.
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
return 0;
}
- /* if filename given on commandline, store it */
+ /* if filename given on command line, store it */
if ((szCmdLine != NULL) && (*szCmdLine != '\0'))
if (szCmdLine[0] == '"')
strncpy (szCmdFileName, szCmdLine + 1, strlen(szCmdLine) - 2);
png_color bkgGray = {127, 127, 127};
png_color bkgWhite = {255, 255, 255};
- /* allocate memory for the Device Independant bitmap */
+ /* allocate memory for the Device Independent bitmap */
wDIRowBytes = (WORD) ((3 * cxWinSize + 3L) >> 2) << 2;
pDib = NULL;
}
+ if (cyWinSize > ((size_t)(-1))/wDIRowBytes) {
+ {
+ MessageBox (hwnd, TEXT ("Visual PNG: image is too big");
+ }
if (!(pDib = (BYTE *) malloc (sizeof(BITMAPINFOHEADER) +
wDIRowBytes * cyWinSize)))
{
cxImgPos = (cxWinSize - cxNewSize) / 2;
}
+ if (cyNewSize > ((size_t)(-1))/(cImgChannels * cxNewSize)) {
+ {
+ MessageBox (hwnd, TEXT ("Visual PNG: stretched image is too big");
+ }
pStretchedImage = malloc (cImgChannels * cxNewSize * cyNewSize);
pImg = pStretchedImage;