]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
switched UTIL_refFilename() to an assert()
authorYann Collet <cyan@fb.com>
Tue, 26 Nov 2019 22:48:23 +0000 (14:48 -0800)
committerYann Collet <cyan@fb.com>
Tue, 26 Nov 2019 22:48:23 +0000 (14:48 -0800)
programs/util.c
programs/util.h

index bb511bd5d5b414256b8d95eb6daa88a946f39c9b..3c541c55040113b33081d1ebc6965cd5220f0e27 100644 (file)
@@ -372,7 +372,7 @@ FileNamesTable* UTIL_allocateFileNamesTable(size_t tableSize)
 
 void UTIL_refFilename(FileNamesTable* fnt, const char* filename)
 {
-    if (fnt->tableCapacity <= fnt->tableSize) abort();
+    assert(fnt->tableSize < fnt->tableCapacity);
     fnt->fileNames[fnt->tableSize] = filename;
     fnt->tableSize++;
 }
index 0065ec46f72c5f01b49e12c1196572ba440587f5..42978b958c27c42cb14b9f299da4f9508d9c3626 100644 (file)
@@ -221,11 +221,10 @@ FileNamesTable* UTIL_allocateFileNamesTable(size_t tableSize);
 
 
 /*! UTIL_refFilename() :
- *  Add a read-only name to reference into @fnt table.
- *  Since @filename is only referenced, its lifetime must outlive @fnt.
- *  This function never fails, but it can abort().
- *  Internal table must be large enough to reference a new member
- *  (capacity > size), otherwise the function will abort().
+ *  Add a reference to read-only name into @fnt table.
+ *  As @filename is only referenced, its lifetime must outlive @fnt.
+ *  Internal table must be large enough to reference a new member,
+ *  otherwise its UB (protected by an `assert()`).
  */
 void UTIL_refFilename(FileNamesTable* fnt, const char* filename);