Author: khornicek
Date: Thu Feb 2 11:07:01 2017
New Revision: 73668
URL:
http://svn.reactos.org/svn/reactos?rev=73668&view=rev
Log:
[CALC]
- Fix a(n) (im)possible buffer overrun. Just a defensive measure in case some future work
on calc would trigger this. CID 716050
Modified:
trunk/reactos/base/applications/calc/winmain.c
Modified: trunk/reactos/base/applications/calc/winmain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/calc/win…
==============================================================================
--- trunk/reactos/base/applications/calc/winmain.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/calc/winmain.c [iso-8859-1] Thu Feb 2 11:07:01 2017
@@ -933,15 +933,18 @@
return FALSE;
}
-static WPARAM idm_2_idc(int idm)
+static BOOL idm_2_idc(int idm, WPARAM *pIdc)
{
int x;
for (x=0; x<SIZEOF(upd); x++) {
if (upd[x].idm == idm)
- break;
- }
- return (WPARAM)(upd[x].idc);
+ {
+ *pIdc = (WPARAM)(upd[x].idc);
+ return TRUE;
+ }
+ }
+ return FALSE;
}
static void CopyMemToClipboard(void *ptr)
@@ -1408,8 +1411,15 @@
case IDM_VIEW_DWORD:
case IDM_VIEW_WORD:
case IDM_VIEW_BYTE:
- SendMessage(hWnd, WM_COMMAND, idm_2_idc(LOWORD(wp)), 0);
- return TRUE;
+ {
+ WPARAM idc;
+ if(idm_2_idc(LOWORD(wp), &idc))
+ {
+ SendMessage(hWnd, WM_COMMAND, idc, 0);
+ return TRUE;
+ }
+ return FALSE;
+ }
case IDM_EDIT_COPY:
handle_copy_command(hWnd);
return TRUE;