diff --git a/src/Helpers.c b/src/Helpers.c index 710a38cbd..437b8fc94 100644 --- a/src/Helpers.c +++ b/src/Helpers.c @@ -2861,6 +2861,7 @@ int ReadStrgsFromCSV(LPCWSTR wchCSVStrg, prefix_t sMatrix[], int const iCount, i for (int i = 0; i < len; ++i) { if (wchTmpBuff[i] == L',') { wchTmpBuff[i] = L'\0'; } } + wchTmpBuff[len + 1] = L'\0'; // double zero at the end // fill default for (int i = 0; i < iCount; ++i) { StringCchCopyW(sMatrix[i], (size_t)iLen, sDefault); } // insert values @@ -2881,7 +2882,7 @@ int ReadStrgsFromCSV(LPCWSTR wchCSVStrg, prefix_t sMatrix[], int const iCount, i // ReadVectorFromString() // // -int ReadVectorFromString(LPCWSTR wchStrg, int* iVector, int iCount, int iMin, int iMax, int iDefault) +int ReadVectorFromString(LPCWSTR wchStrg, int iVector[], int iCount, int iMin, int iMax, int iDefault) { static WCHAR wchTmpBuff[SMALL_BUFFER]; @@ -2898,6 +2899,8 @@ int ReadVectorFromString(LPCWSTR wchStrg, int* iVector, int iCount, int iMin, in for (int i = 0; i < len; ++i) { if (wchTmpBuff[i] == L' ') { wchTmpBuff[i] = L'\0'; } } + wchTmpBuff[len + 1] = L'\0'; // double zero at the end + // fill default for (int i = 0; i < iCount; ++i) { iVector[i] = iDefault; } // insert values diff --git a/src/Helpers.h b/src/Helpers.h index bf14df4e0..be66db0f8 100644 --- a/src/Helpers.h +++ b/src/Helpers.h @@ -388,7 +388,7 @@ __forceinline int GetHexDigit(char ch) { void UrlUnescapeEx(LPWSTR, LPWSTR, DWORD*); int ReadStrgsFromCSV(LPCWSTR wchCSVStrg, prefix_t sMatrix[], int const iCount, int const iLen, LPCWSTR sDefault); -int ReadVectorFromString(LPCWSTR wchStrg, int* iVector, int iCount, int iMin, int iMax, int iDefault); +int ReadVectorFromString(LPCWSTR wchStrg, int iVector[], int iCount, int iMin, int iMax, int iDefault); // -------------------------------------------------------------------------------------------------------------------------------- diff --git a/src/Notepad3.c b/src/Notepad3.c index 84fe4e272..32083e5fd 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -143,12 +143,12 @@ static WCHAR g_tchStatusbarPrefixes[MIDSZ_BUFFER] = { L'\0' }; static prefix_t g_mxStatusBarPrefix[STATUS_SECTOR_COUNT]; static WCHAR g_tchStatusbarSections[SMALL_BUFFER] = { L'\0' }; -static int g_iStatusbarSections[STATUS_SECTOR_COUNT]; -static bool g_iStatusbarVisible[STATUS_SECTOR_COUNT]; -static int g_vSBSOrder[STATUS_SECTOR_COUNT]; +static int g_iStatusbarSections[STATUS_SECTOR_COUNT] = SBS_INIT_MINUS; +static bool g_iStatusbarVisible[STATUS_SECTOR_COUNT] = SBS_INIT_ZERO; +static int g_vSBSOrder[STATUS_SECTOR_COUNT] = SBS_INIT_MINUS; static WCHAR g_tchStatusbarWidthSpec[SMALL_BUFFER] = { L'\0' }; -static int g_iStatusbarWidthSpec[STATUS_SECTOR_COUNT]; +static int g_iStatusbarWidthSpec[STATUS_SECTOR_COUNT] = SBS_INIT_ZERO; static WCHAR g_tchToolbarBitmap[MAX_PATH] = { L'\0' }; @@ -7776,7 +7776,7 @@ void UpdateStatusbar() _CalculateStatusbarSections(g_vStatusbarSectionWidth, tchStatusBar); - int aStatusbarSections[STATUS_SECTOR_COUNT]; + int aStatusbarSections[STATUS_SECTOR_COUNT] = SBS_INIT_ZERO; int cnt = 0; int totalWidth = 0; for (int i = 0; i < STATUS_SECTOR_COUNT; ++i) { diff --git a/src/TypeDefs.h b/src/TypeDefs.h index 5dc557cad..86dffa146 100644 --- a/src/TypeDefs.h +++ b/src/TypeDefs.h @@ -91,6 +91,7 @@ typedef enum { #define SBS_INIT_ZERO { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } #define SBS_INIT_MINUS { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } +#define SBS_INIT_ORDER { 0, 1, 2, 3, 4, 5, 6, 7. 8. 9, 10, 11 } #define STATUSBAR_EXTION_PREFIXES L"Ln ,Col ,Sel ,Sb ,SLn ,Occ ,,,,,,," #define STATUSBAR_DEFAULT_IDS L"0 1 2 4 5 6 7 8 9 10 11"