diff --git a/src/java.base/windows/native/libnet/NetworkInterface.c b/src/java.base/windows/native/libnet/NetworkInterface.c index 9ff1a828f0b..74eb95c7225 100644 --- a/src/java.base/windows/native/libnet/NetworkInterface.c +++ b/src/java.base/windows/native/libnet/NetworkInterface.c @@ -273,7 +273,7 @@ int enumInterfaces(JNIEnv *env, netif **netifPP) // But in rare case it fails, we allow 'char' to be displayed curr->displayName = (char *)malloc(ifrowP->dwDescrLen + 1); } else { - curr->displayName = (wchar_t *)malloc(wlen*(sizeof(wchar_t))+1); + curr->displayName = (wchar_t *)malloc((wlen+1)*sizeof(wchar_t)); } curr->name = (char *)malloc(strlen(dev_name) + 1); @@ -316,7 +316,7 @@ int enumInterfaces(JNIEnv *env, netif **netifPP) free(curr); return -1; } else { - curr->displayName[wlen*(sizeof(wchar_t))] = '\0'; + ((wchar_t *)curr->displayName)[wlen] = L'\0'; curr->dNameIsUnicode = TRUE; } }