[ROSAPPS][VGAFONTEDIT] String/Memory check

This commit is contained in:
Katayama Hirofumi MZ 2018-12-20 22:33:59 +09:00
parent fb8fe4a08c
commit 56297438a5
2 changed files with 29 additions and 9 deletions

View file

@ -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( DoOpenFile(OpenInfo->pszFileName) )
if (OpenInfo->pszFileName)
{
OpenInfo->bCreateNew = FALSE;
CreateFontWindow(Info, OpenInfo);
OpenInfo->pszFileName[0] = 0;
if (DoOpenFile(OpenInfo->pszFileName))
{
OpenInfo->bCreateNew = FALSE;
CreateFontWindow(Info, OpenInfo);
}
}
else
{
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

View file

@ -11,6 +11,7 @@
#include <windows.h>
#include <windowsx.h>
#include <commctrl.h>
#include <strsafe.h>
#include "resource.h"
#include "customwndclasses.h"