- fix a leak
- fix a buffer overrun
CID #503741
CID #716119

svn path=/trunk/; revision=62685
This commit is contained in:
Kamil Hornicek 2014-04-08 00:14:44 +00:00
parent 5cd83d03a1
commit 7fe5a44dfa
2 changed files with 13 additions and 4 deletions

View file

@ -57,6 +57,9 @@ FindDateSep(const TCHAR *szSourceStr)
pszFoundSep = (LPTSTR)malloc(MAX_SAMPLES_STR_SIZE * sizeof(TCHAR)); pszFoundSep = (LPTSTR)malloc(MAX_SAMPLES_STR_SIZE * sizeof(TCHAR));
if(!pszFoundSep)
return NULL;
_tcscpy(pszFoundSep,STD_DATE_SEP); _tcscpy(pszFoundSep,STD_DATE_SEP);
while (nDateCompCount < _tcslen(szSourceStr)) while (nDateCompCount < _tcslen(szSourceStr))
@ -121,8 +124,9 @@ SetShortDateFormat(HWND hwndDlg, LCID lcid)
{ {
TCHAR szShortDateFmt[MAX_SAMPLES_STR_SIZE]; TCHAR szShortDateFmt[MAX_SAMPLES_STR_SIZE];
TCHAR szShortDateSep[MAX_SAMPLES_STR_SIZE]; TCHAR szShortDateSep[MAX_SAMPLES_STR_SIZE];
TCHAR szFindedDateSep[MAX_SAMPLES_STR_SIZE]; TCHAR szFoundDateSep[MAX_SAMPLES_STR_SIZE];
LPTSTR pszResultStr; LPTSTR pszResultStr;
LPTSTR pszFoundSep;
BOOL OpenApostFlg = FALSE; BOOL OpenApostFlg = FALSE;
INT nFmtStrSize; INT nFmtStrSize;
INT nDateCompCount; INT nDateCompCount;
@ -166,12 +170,17 @@ SetShortDateFormat(HWND hwndDlg, LCID lcid)
return FALSE; return FALSE;
} }
pszFoundSep = FindDateSep(szShortDateFmt);
/* Substring replacement of separator */ /* Substring replacement of separator */
_tcscpy(szFindedDateSep, FindDateSep(szShortDateFmt)); _tcscpy(szFoundDateSep, pszFoundSep);
pszResultStr = ReplaceSubStr(szShortDateFmt, szShortDateSep, szFindedDateSep); pszResultStr = ReplaceSubStr(szShortDateFmt, szShortDateSep, szFoundDateSep);
_tcscpy(szShortDateFmt, pszResultStr); _tcscpy(szShortDateFmt, pszResultStr);
free(pszResultStr); free(pszResultStr);
if(pszFoundSep)
free(pszFoundSep);
/* Save short date format */ /* Save short date format */
SetLocaleInfo(lcid, LOCALE_SSHORTDATE, szShortDateFmt); SetLocaleInfo(lcid, LOCALE_SSHORTDATE, szShortDateFmt);

View file

@ -134,7 +134,7 @@ CreateSortList(HWND hwnd, LCID lcid)
/* Select current locale */ /* Select current locale */
/* or should it be System and not user? */ /* or should it be System and not user? */
GetLocaleInfo(lcid, LOCALE_SSORTNAME, lang, sizeof(lang)); GetLocaleInfo(lcid, LOCALE_SSORTNAME, lang, sizeof(lang)/sizeof(TCHAR));
SendMessage(hwnd, SendMessage(hwnd,
CB_SELECTSTRING, CB_SELECTSTRING,