Use (std::nothrow) with new when the code check for null pointer results.
This commit is contained in:
parent
b71292464e
commit
0f99c2d712
@ -217,7 +217,7 @@ filepos_t EbmlCrc32::RenderData(IOCallback & output, bool /* bForceRender */, bo
|
||||
|
||||
if (Result < GetDefaultSize()) {
|
||||
// pad the rest with 0
|
||||
binary *Pad = new binary[GetDefaultSize() - Result];
|
||||
binary *Pad = new (std::nothrow) binary[GetDefaultSize() - Result];
|
||||
if (Pad != NULL) {
|
||||
memset(Pad, 0x00, GetDefaultSize() - Result);
|
||||
output.writeFully(Pad, GetDefaultSize() - Result);
|
||||
@ -234,7 +234,7 @@ filepos_t EbmlCrc32::ReadData(IOCallback & input, ScopeMode ReadFully)
|
||||
{
|
||||
if (ReadFully != SCOPE_NO_DATA)
|
||||
{
|
||||
binary *Buffer = new binary[GetSize()];
|
||||
binary *Buffer = new (std::nothrow) binary[GetSize()];
|
||||
if (Buffer == NULL) {
|
||||
// impossible to read, skip it
|
||||
input.setFilePointer(GetSize(), seek_current);
|
||||
|
@ -317,7 +317,9 @@ EbmlElement * EbmlElement::FindNextID(IOCallback & DataStream, const EbmlCallbac
|
||||
Result = &EBML_INFO_CREATE(ClassInfos);
|
||||
} else {
|
||||
/// \todo find the element in the context
|
||||
Result = new EbmlDummy(PossibleID);
|
||||
Result = new (std::nothrow) EbmlDummy(PossibleID);
|
||||
if(Result == NULL)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Result->SetSizeLength(PossibleSizeLength);
|
||||
@ -565,7 +567,7 @@ EbmlElement *EbmlElement::CreateElementUsingContext(const EbmlId & aID, const Eb
|
||||
|
||||
if (!IsGlobalContext && bAllowDummy) {
|
||||
LowLevel = 0;
|
||||
Result = new EbmlDummy(aID);
|
||||
Result = new (std::nothrow) EbmlDummy(aID);
|
||||
}
|
||||
|
||||
return Result;
|
||||
|
@ -95,7 +95,7 @@ filepos_t EbmlString::RenderData(IOCallback & output, bool /* bForceRender */, b
|
||||
|
||||
if (Result < GetDefaultSize()) {
|
||||
// pad the rest with 0
|
||||
binary *Pad = new binary[GetDefaultSize() - Result];
|
||||
binary *Pad = new (std::nothrow) binary[GetDefaultSize() - Result];
|
||||
if (Pad == NULL)
|
||||
{
|
||||
return Result;
|
||||
@ -151,7 +151,7 @@ filepos_t EbmlString::ReadData(IOCallback & input, ScopeMode ReadFully)
|
||||
Value = "";
|
||||
SetValueIsSet();
|
||||
} else {
|
||||
char *Buffer = new char[GetSize() + 1];
|
||||
char *Buffer = new (std::nothrow) char[GetSize() + 1];
|
||||
if (Buffer == NULL) {
|
||||
// unable to store the data, skip it
|
||||
input.setFilePointer(GetSize(), seek_current);
|
||||
|
@ -273,7 +273,7 @@ filepos_t EbmlUnicodeString::RenderData(IOCallback & output, bool /* bForceRende
|
||||
|
||||
if (Result < GetDefaultSize()) {
|
||||
// pad the rest with 0
|
||||
binary *Pad = new binary[GetDefaultSize() - Result];
|
||||
binary *Pad = new (std::nothrow) binary[GetDefaultSize() - Result];
|
||||
if (Pad != NULL) {
|
||||
memset(Pad, 0x00, GetDefaultSize() - Result);
|
||||
output.writeFully(Pad, GetDefaultSize() - Result);
|
||||
@ -339,7 +339,7 @@ filepos_t EbmlUnicodeString::ReadData(IOCallback & input, ScopeMode ReadFully)
|
||||
Value = UTFstring::value_type(0);
|
||||
SetValueIsSet();
|
||||
} else {
|
||||
char *Buffer = new char[GetSize()+1];
|
||||
char *Buffer = new (std::nothrow) char[GetSize()+1];
|
||||
if (Buffer == NULL) {
|
||||
// impossible to read, skip it
|
||||
input.setFilePointer(GetSize(), seek_current);
|
||||
|
Loading…
x
Reference in New Issue
Block a user