Fixed null-termination bug

This commit is contained in:
hedgecrw85 2018-04-02 15:38:20 -05:00
parent fc3a85f377
commit 95abbc35e3
3 changed files with 2 additions and 2 deletions

View File

@ -272,9 +272,9 @@ JNIEXPORT jobjectArray JNICALL Java_com_fazecast_jSerialComm_SerialPort_getCommP
for (j = 0; j < serialCommPorts.length; ++j)
if (wcscmp(serialCommPorts.first[j], comPortString) == 0)
{
size_t descLength = strlen(devInfo[i].Description);
size_t descLength = 8+strlen(devInfo[i].Description);
free(serialCommPorts.third[j]);
serialCommPorts.third[j] = (wchar_t*)malloc((descLength+1)*sizeof(wchar_t));
serialCommPorts.third[j] = (wchar_t*)malloc(descLength*sizeof(wchar_t));
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, devInfo[i].Description, -1, serialCommPorts.third[j], descLength);
break;
}