[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 = (PFONT_OPEN_INFO) HeapAlloc( hProcessHeap, HEAP_ZERO_MEMORY, sizeof(FONT_OPEN_INFO) );
OpenInfo->pszFileName = HeapAlloc(hProcessHeap, 0, MAX_PATH); OpenInfo->pszFileName = HeapAlloc(hProcessHeap, 0, MAX_PATH);
OpenInfo->pszFileName[0] = 0; if (OpenInfo->pszFileName)
if( DoOpenFile(OpenInfo->pszFileName) )
{ {
OpenInfo->bCreateNew = FALSE; OpenInfo->pszFileName[0] = 0;
CreateFontWindow(Info, OpenInfo);
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 = HeapAlloc(hProcessHeap, HEAP_ZERO_MEMORY, sizeof(FONT_OPEN_INFO));
OpenInfo->pszFileName = HeapAlloc(hProcessHeap, 0, MAX_PATH); OpenInfo->pszFileName = HeapAlloc(hProcessHeap, 0, MAX_PATH);
lstrcpynW(OpenInfo->pszFileName, File, MAX_PATH); if (OpenInfo->pszFileName)
{
OpenInfo->bCreateNew = FALSE; if (StringCchCopyW(OpenInfo->pszFileName, MAX_PATH, File) == S_OK)
CreateFontWindow(Info, OpenInfo); {
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 static VOID

View file

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