'Compiler Warning C6385 - Win32Api - Windows GUI Application [SOLVED]

I am getting some compiler warnings, but I don't know how to fix them. I couldn't find the answer myself.

int64_t ID = 0;
ID = (int64_t)LOWORD(wParam) - 203;
std::wstring numbersPositive[] = { L"0", L"1", L"2", L"3", L"4", L"5", L"6", L"7", L"8", L"9" };
std::wstring numbersNegative[] = { L"-0", L"-1", L"-2", L"-3", L"-4", L"-5", L"-6", L"-7", L"-8", L"-9" };

TCHAR Text[MAX_CALCULATOR_OUTPUT_STRING] = { 0 };
GetWindowText(hCalculatorOutput, Text, ARRAYSIZE(Text));
std::wstring WText = Text;
if (WText == L"0") {
    SetWindowText(hCalculatorOutput, numbersPositive[ID].c_str());
} 
else if (WText[0] == L'-' && WText[1] == L'0' && WText.length() == 2) {
    SetWindowText(hCalculatorOutput, numbersNegative[ID].c_str()); // Compiler Warning C6385
}
else {
    int64_t length = WText.length();
    if (length <= ARRAYSIZE(Text) - 2) {
        WText = WText + numbersPositive[ID]; // Compiler Warning C6385
        SetWindowText(hCalculatorOutput, WText.c_str());
    }
    else {
        MessageBeep(MB_ICONINFORMATION);
    }
}

Warning C6385 Reading invalid data from numbersNegative: the readable size is 400 bytes, but 2613320 bytes may be read.

Warning C6385 Reading invalid data from numbersPositive: the readable size is 400 bytes, but 2613320 bytes may be read.

vvv Working Code Below vvv

    case 203: case 204: case 205: case 206:
    case 207: case 208: case 209: case 210:
    case 211: case 212:
    {
        int64_t ID = 0;
        ID = (int64_t)LOWORD(wParam) % 10;
        (ID >= 3 && ID <= 9) ? ID = ID - 3 : (ID >= 0 && ID <= 2) ? ID = ID + 7 : ID = 0;
        std::wstring numbersPositive[] = { L"0", L"1", L"2", L"3", L"4", L"5", L"6", L"7", L"8", L"9" };
        std::wstring numbersNegative[] = { L"-0", L"-1", L"-2", L"-3", L"-4", L"-5", L"-6", L"-7", L"-8", L"-9" };

        TCHAR Text[MAX_CALCULATOR_OUTPUT_STRING] = { 0 };
        TCHAR ErrorText[40] = { 0 };
        GetWindowText(hCalculatorOutput, Text, ARRAYSIZE(Text));
        GetWindowText(hCalculatorOutput, ErrorText, ARRAYSIZE(ErrorText));
        std::wstring WText = Text;
        std::wstring WErrorText = ErrorText;
        std::wstring temp1 = numbersPositive[ID];
        std::wstring temp2 = numbersNegative[ID];
        int64_t length = WText.length();
        if (WText == L"0" || WErrorText == L"Infinity" || WErrorText == L"Cannot Divide by Zero") {
            WText = temp1;
            SetWindowText(hCalculatorOutput, WText.c_str());
        }
        else if (WText[0] == L'-' && WText[1] == L'0' && length == 2) {
            WText = temp2;
            SetWindowText(hCalculatorOutput, WText.c_str());
        }
        else {
            if (length < ARRAYSIZE(Text) - 1) {
                WText = WText + temp1;
                SetWindowText(hCalculatorOutput, WText.c_str());
            }
            else {
                MessageBeep(MB_ICONINFORMATION);
            }
        }
        break;
    }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source