Potential Memory Corruption in Release Build (#3559)

* Potential Memory Corruption in Release Build

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

* @lumberyard-employee-dm suggested code

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

* warnings as errors found in VS2022

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

* simplifying some strucutres used and fixing a bug

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

* some unused fixes for VS2022

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

* fix for other platforms

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

* fixes check used in unit tests to be case-insensitive
fixes memory leaks/invalid memory operations in AWSCore tests

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
Esteban Papp
2021-08-26 15:59:40 -07:00
committed by GitHub
parent 9f55212a19
commit 1be95a1e76
20 changed files with 93 additions and 108 deletions
@@ -100,7 +100,7 @@ namespace AZ
char resolvedPath[AZ_MAX_PATH_LEN];
ResolvePath(filePath, resolvedPath, AZ_MAX_PATH_LEN);
AZ::OSString pathWithoutSlash = RemoveTrailingSlash(resolvedPath);
AZStd::string pathWithoutSlash = RemoveTrailingSlash(resolvedPath);
bool isInAPK = AZ::Android::Utils::IsApkPath(pathWithoutSlash.c_str());
if (isInAPK)
@@ -115,7 +115,7 @@ namespace AZ
// Skip over the current and parent directory paths
if (filenameView != "." && filenameView != ".." && NameMatchesFilter(name, filter))
{
AZ::OSString foundFilePath = CheckForTrailingSlash(resolvedPath);
AZStd::string foundFilePath = CheckForTrailingSlash(resolvedPath);
foundFilePath += name;
// if aliased, de-alias!
azstrcpy(tempBuffer, AZ_MAX_PATH_LEN, foundFilePath.c_str());
@@ -150,7 +150,7 @@ namespace AZ
// Skip over the current and parent directory paths
if (filenameView != "." && filenameView != ".." && NameMatchesFilter(entry->d_name, filter))
{
AZ::OSString foundFilePath = CheckForTrailingSlash(resolvedPath);
AZStd::string foundFilePath = CheckForTrailingSlash(resolvedPath);
foundFilePath += entry->d_name;
// if aliased, de-alias!
azstrcpy(tempBuffer, AZ_MAX_PATH_LEN, foundFilePath.c_str());
@@ -199,7 +199,7 @@ namespace AZ
}
// make directories from bottom to top.
AZ::OSString pathBuffer;
AZStd::string pathBuffer;
size_t pathLength = strlen(resolvedPath);
pathBuffer.reserve(pathLength);
for (size_t pathPos = 0; pathPos < pathLength; ++pathPos)