Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions ini.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,17 @@ int INIClass::Load(Straw& straw)
line[0] = ' ';
*strchr(line, ']') = '\0';
strtrim(line);
INISection* section = new INISection(newstr(line));
if (!section)
{
Clear(0, 0);
return false;

INISection* section;

try {
section = new INISection(newstr(line));
}
catch (std::bad_alloc& ba) {
Clear(0, 0);
return false;
}

while (!isLastLine)
{
int count = Read_Line(cacheStraw, line, 512, isLastLine);
Expand All @@ -146,13 +151,17 @@ int INIClass::Load(Straw& straw)
{
continue;
}
INIEntry* entry = new INIEntry(newstr(key), newstr(value));
if (!entry)
{
delete section;
Clear(0, 0);
return false;

INIEntry* entry;
try {
entry = new INIEntry(newstr(key), newstr(value));
}
catch (std::bad_alloc& ba) {
delete section;
Clear(0, 0);
return false;
}

uint32 crc = CRC_String(entry->Entry, 0);
if (section->EntryIndex.Is_Present(crc))
DuplicateCRCError(__FUNCTION__, section->Section, line);
Expand Down
20 changes: 13 additions & 7 deletions vector.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once
#include "CriticalSectionClass.h"
#include <new>

template <typename T> class NoEqualsClass
{
public:
Expand Down Expand Up @@ -55,15 +57,16 @@ template <class T> class VectorClass {
VectorMax = vector.Length();
if (VectorMax)
{
Vector = new T[VectorMax];
if (Vector)
{
try {
Vector = new T[VectorMax];
IsAllocated = true;
for (int index = 0; index < VectorMax; index++)
{
Vector[index] = vector[index];
}
}
catch (std::bad_alloc& ba) {
}
}
else
{
Expand Down Expand Up @@ -1226,11 +1229,12 @@ template <typename T1,class T2> class IndexClass {
if (amount >= 0)
{
int newsize = IndexSize + amount;
NodeElement *newindex = new NodeElement[newsize];
if (newindex)
{

NodeElement *newindex;
try {
newindex = new NodeElement[newsize];
UL_ASSERT(IndexCount < newsize);
for (int i = 0;i < this->IndexCount;i++)
for (int i = 0; i < this->IndexCount; i++)
{
newindex[i].ID = IndexTable[i].ID;
newindex[i].Data = IndexTable[i].Data;
Expand All @@ -1242,6 +1246,8 @@ template <typename T1,class T2> class IndexClass {
Invalidate_Archive();
return true;
}
catch (std::bad_alloc& ba) {
}
}
return false;
}
Expand Down