mirror of https://github.com/wolfSSL/wolfssh.git
free unicodeOldName on error paths
WS_MoveFileA allocated unicodeOldName but did not free it when the follow-up mbstowcs_s calls failed. Check the conversion result after filling unicodeOldName, and free it before returning when the sizing call for unicodeNewName fails. Affected function: WS_MoveFileA. Issue: F-50pull/968/head
parent
90d5d44910
commit
9ea6c7930d
|
|
@ -456,13 +456,19 @@ int WS_MoveFileA(const char* oldName, const char* newName, void* heap)
|
|||
|
||||
error = mbstowcs_s(&returnSz, unicodeOldName, unicodeOldNameSz,
|
||||
oldName, oldNameSz);
|
||||
if (error != 0) {
|
||||
WFREE(unicodeOldName, heap, PORT_DYNTYPE_STRING);
|
||||
return 0;
|
||||
}
|
||||
|
||||
newNameSz = WSTRLEN(newName);
|
||||
newName = TrimFileName(newName, &newNameSz);
|
||||
|
||||
error = mbstowcs_s(&unicodeNewNameSz, NULL, 0, newName, 0);
|
||||
if (error != 0)
|
||||
if (error != 0) {
|
||||
WFREE(unicodeOldName, heap, PORT_DYNTYPE_STRING);
|
||||
return 0;
|
||||
}
|
||||
|
||||
unicodeNewName = (wchar_t*)WMALLOC((unicodeNewNameSz+1)*sizeof(wchar_t),
|
||||
heap, PORT_DYNTYPE_STRING);
|
||||
|
|
|
|||
Loading…
Reference in New Issue