File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -391,6 +391,10 @@ class SaveArchive : public OutputArchive<SaveArchive>
391
391
392
392
// Construct the buffer
393
393
char *compBuffer = (char *)malloc (LZ4_compressBound (offset_));
394
+ if (compBuffer == NULL ) {
395
+ throw FLANNException (" Error allocating compression buffer" );
396
+ }
397
+
394
398
size_t headSz = sizeof (IndexHeaderStruct);
395
399
memcpy (compBuffer, buffer_, headSz);
396
400
@@ -436,6 +440,9 @@ class SaveArchive : public OutputArchive<SaveArchive>
436
440
void save (const T& val)
437
441
{
438
442
buffer_ = (char *)realloc (buffer_, offset_+sizeof (val));
443
+ if (buffer_ == NULL ) {
444
+ throw FLANNException (" Error reallocating compression buffer (save_binary())" );
445
+ }
439
446
memcpy (buffer_+offset_, &val, sizeof (val));
440
447
offset_ += sizeof (val);
441
448
}
@@ -451,6 +458,9 @@ class SaveArchive : public OutputArchive<SaveArchive>
451
458
void save_binary (T* ptr, size_t size)
452
459
{
453
460
buffer_ = (char *)realloc (buffer_, offset_+size);
461
+ if (buffer_ == NULL ) {
462
+ throw FLANNException (" Error reallocating compression buffer (save_binary())" );
463
+ }
454
464
memcpy (buffer_+offset_, ptr, size);
455
465
offset_ += size;
456
466
}
You can’t perform that action at this time.
0 commit comments