https://git.reactos.org/?p=reactos.git;a=commitdiff;h=56297438a57a410ad485a…
commit 56297438a57a410ad485a84efe4e7c2adfa41ed9
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Thu Dec 20 22:33:59 2018 +0900
Commit: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
CommitDate: Thu Dec 20 22:33:59 2018 +0900
[ROSAPPS][VGAFONTEDIT] String/Memory check
---
.../applications/devutils/vgafontedit/mainwnd.c | 35 +++++++++++++++++-----
.../applications/devutils/vgafontedit/precomp.h | 1 +
2 files changed, 28 insertions(+), 8 deletions(-)
diff --git a/modules/rosapps/applications/devutils/vgafontedit/mainwnd.c
b/modules/rosapps/applications/devutils/vgafontedit/mainwnd.c
index fd708491bf..8057df50d7 100644
--- a/modules/rosapps/applications/devutils/vgafontedit/mainwnd.c
+++ b/modules/rosapps/applications/devutils/vgafontedit/mainwnd.c
@@ -213,12 +213,19 @@ DoFileOpen(IN PMAIN_WND_INFO Info)
OpenInfo = (PFONT_OPEN_INFO) HeapAlloc( hProcessHeap, HEAP_ZERO_MEMORY,
sizeof(FONT_OPEN_INFO) );
OpenInfo->pszFileName = HeapAlloc(hProcessHeap, 0, MAX_PATH);
- OpenInfo->pszFileName[0] = 0;
+ if (OpenInfo->pszFileName)
+ {
+ OpenInfo->pszFileName[0] = 0;
- if( DoOpenFile(OpenInfo->pszFileName) )
+ if (DoOpenFile(OpenInfo->pszFileName))
+ {
+ OpenInfo->bCreateNew = FALSE;
+ CreateFontWindow(Info, OpenInfo);
+ }
+ }
+ else
{
- OpenInfo->bCreateNew = FALSE;
- CreateFontWindow(Info, OpenInfo);
+ MessageBoxW(Info->hMainWnd, L"Out of memory!", NULL, MB_ICONERROR);
}
}
@@ -229,10 +236,22 @@ MainWndOpenFile(IN PMAIN_WND_INFO Info, LPCWSTR File)
OpenInfo = HeapAlloc(hProcessHeap, HEAP_ZERO_MEMORY, sizeof(FONT_OPEN_INFO));
OpenInfo->pszFileName = HeapAlloc(hProcessHeap, 0, MAX_PATH);
- lstrcpynW(OpenInfo->pszFileName, File, MAX_PATH);
-
- OpenInfo->bCreateNew = FALSE;
- CreateFontWindow(Info, OpenInfo);
+ if (OpenInfo->pszFileName)
+ {
+ if (StringCchCopyW(OpenInfo->pszFileName, MAX_PATH, File) == S_OK)
+ {
+ OpenInfo->bCreateNew = FALSE;
+ CreateFontWindow(Info, OpenInfo);
+ }
+ else
+ {
+ MessageBoxW(Info->hMainWnd, L"Pathname is too long!", NULL,
MB_ICONERROR);
+ }
+ }
+ else
+ {
+ MessageBoxW(Info->hMainWnd, L"Out of memory!", NULL, MB_ICONERROR);
+ }
}
static VOID
diff --git a/modules/rosapps/applications/devutils/vgafontedit/precomp.h
b/modules/rosapps/applications/devutils/vgafontedit/precomp.h
index 7728310f5e..94ac9ddfbf 100644
--- a/modules/rosapps/applications/devutils/vgafontedit/precomp.h
+++ b/modules/rosapps/applications/devutils/vgafontedit/precomp.h
@@ -11,6 +11,7 @@
#include <windows.h>
#include <windowsx.h>
#include <commctrl.h>
+#include <strsafe.h>
#include "resource.h"
#include "customwndclasses.h"