Fix for problems signaled by clang static analyzer
Former-commit-id: 835f639c45509b0d55fe716e51e3285ea2a89da4
This commit is contained in:
@@ -143,7 +143,18 @@ namespace Nz
|
||||
return false;
|
||||
}
|
||||
|
||||
mode_t permissions; // TODO : get permission from first file
|
||||
mode_t permissions;
|
||||
struct stat sb;
|
||||
if (fstat(fd1, &sb) == -1) // get permission from first file
|
||||
{
|
||||
NazaraWarning("Could not get permissions of source file");
|
||||
permissions = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
|
||||
}
|
||||
else
|
||||
{
|
||||
permissions = sb.st_mode & ~S_IFMT; // S_IFMT: bit mask for the file type bit field -> ~S_IFMT: general permissions
|
||||
}
|
||||
|
||||
int fd2 = open64(targetPath.GetConstBuffer(), O_WRONLY | O_TRUNC, permissions);
|
||||
if (fd2 == -1)
|
||||
{
|
||||
|
||||
@@ -2827,21 +2827,15 @@ namespace Nz
|
||||
{
|
||||
const char* c = oldCharacters;
|
||||
char character = Detail::ToLower(*ptr);
|
||||
bool found = false;
|
||||
|
||||
std::ptrdiff_t offset = ptr - m_sharedString->string.get();
|
||||
EnsureOwnership();
|
||||
ptr = &m_sharedString->string[offset];
|
||||
|
||||
do
|
||||
{
|
||||
if (character == Detail::ToLower(*c))
|
||||
{
|
||||
if (!found)
|
||||
{
|
||||
std::ptrdiff_t offset = ptr - m_sharedString->string.get();
|
||||
|
||||
EnsureOwnership();
|
||||
|
||||
ptr = &m_sharedString->string[offset];
|
||||
found = true;
|
||||
}
|
||||
|
||||
*ptr = replaceCharacter;
|
||||
++count;
|
||||
break;
|
||||
@@ -2853,19 +2847,12 @@ namespace Nz
|
||||
}
|
||||
else
|
||||
{
|
||||
bool found = false;
|
||||
std::ptrdiff_t offset = ptr - m_sharedString->string.get();
|
||||
EnsureOwnership();
|
||||
ptr = &m_sharedString->string[offset];
|
||||
|
||||
while ((ptr = std::strpbrk(ptr, oldCharacters)) != nullptr)
|
||||
{
|
||||
if (!found)
|
||||
{
|
||||
std::ptrdiff_t offset = ptr - m_sharedString->string.get();
|
||||
|
||||
EnsureOwnership();
|
||||
|
||||
ptr = &m_sharedString->string[offset];
|
||||
found = true;
|
||||
}
|
||||
|
||||
*ptr++ = replaceCharacter;
|
||||
++count;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user