[misc] fix a potential resource leak

* IsFontAvailable() could exit without releasing its 'hDC' handle resulting in a resource leak
* Fix V773 from PSV-Studio
* Closes #1050
This commit is contained in:
ip_gpu 2017-10-27 14:29:03 +05:00 committed by Pete Batard
parent 6a45a678b3
commit fa94abcc8e
2 changed files with 8 additions and 6 deletions

View file

@ -634,8 +634,10 @@ BOOL IsFontAvailable(const char* font_name) {
LOGFONTA lf = { 0 };
HDC hDC = GetDC(hMainDialog);
if (font_name == NULL)
if (font_name == NULL) {
ReleaseDC(hMainDialog, hDC);
return FALSE;
}
lf.lfCharSet = DEFAULT_CHARSET;
safe_strcpy(lf.lfFaceName, LF_FACESIZE, font_name);