Author: zguo
Date: Wed Dec 10 21:27:18 2014
New Revision: 65602
URL:
http://svn.reactos.org/svn/reactos?rev=65602&view=rev
Log:
[SHIMGVW]
Dynamically allocate the string for the file-type box. Patch by Ricardo Hanke.
CORE-7702 #resolve
Modified:
trunk/reactos/dll/win32/shimgvw/shimgvw.c
Modified: trunk/reactos/dll/win32/shimgvw/shimgvw.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shimgvw/shimgvw.…
==============================================================================
--- trunk/reactos/dll/win32/shimgvw/shimgvw.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shimgvw/shimgvw.c [iso-8859-1] Wed Dec 10 21:27:18 2014
@@ -76,7 +76,7 @@
OPENFILENAMEW sfn;
ImageCodecInfo *codecInfo;
WCHAR szSaveFileName[MAX_PATH];
- WCHAR szFilterMask[2048];
+ WCHAR *szFilterMask;
GUID rawFormat;
UINT num;
UINT size;
@@ -84,8 +84,38 @@
UINT j;
WCHAR *c;
+ GdipGetImageEncodersSize(&num, &size);
+ codecInfo = malloc(size);
+ if (!codecInfo)
+ {
+ DPRINT1("malloc() failed in pSaveImageAs()\n");
+ return;
+ }
+
+ GdipGetImageEncoders(num, size, codecInfo);
+ GdipGetImageRawFormat(image, &rawFormat);
+
+ sizeRemain = 0;
+
+ for (j = 0; j < num; ++j)
+ {
+ // Every pair needs space for the Description, twice the Extensions, 1 char for
the space, 2 for the braces and 2 for the NULL terminators.
+ sizeRemain = sizeRemain + (((wcslen(codecInfo[j].FormatDescription) +
(wcslen(codecInfo[j].FilenameExtension) * 2) + 5) * sizeof(WCHAR)));
+ }
+
+ /* Add two more chars for the last terminator */
+ sizeRemain = sizeRemain + (sizeof(WCHAR) * 2);
+
+ szFilterMask = malloc(sizeRemain);
+ if (!szFilterMask)
+ {
+ DPRINT1("cannot allocate memory for filter mask in pSaveImageAs()");
+ free(codecInfo);
+ return;
+ }
+
ZeroMemory(szSaveFileName, sizeof(szSaveFileName));
- ZeroMemory(szFilterMask, sizeof(szFilterMask));
+ ZeroMemory(szFilterMask, sizeRemain);
ZeroMemory(&sfn, sizeof(sfn));
sfn.lStructSize = sizeof(sfn);
sfn.hwndOwner = hwnd;
@@ -95,18 +125,6 @@
sfn.nMaxFile = MAX_PATH;
sfn.Flags = OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
- GdipGetImageEncodersSize(&num, &size);
- codecInfo = malloc(size);
- if (!codecInfo)
- {
- DPRINT1("malloc() failed in pSaveImageAs()\n");
- return;
- }
-
- GdipGetImageEncoders(num, size, codecInfo);
- GdipGetImageRawFormat(image, &rawFormat);
-
- sizeRemain = sizeof(szFilterMask);
c = szFilterMask;
for (j = 0; j < num; ++j)
@@ -137,6 +155,7 @@
}
}
+ free(szFilterMask);
free(codecInfo);
}