]> git.lyx.org Git - lyx.git/commitdiff
Do not use rand() to set a BranchList id
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 13 Sep 2024 09:07:05 +0000 (11:07 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 13 Sep 2024 09:09:30 +0000 (11:09 +0200)
Use a simple counting instead, beecause Coverity complains that rand()
is not safe, and counting is siimpler anyway.

src/BranchList.cpp
src/BranchList.h

index fc61065a4b767bf34099498466883204a2e55245..37e746293d2c7c5fb720a82524059660176bc1a8 100644 (file)
@@ -32,6 +32,11 @@ docstring const & Branch::branch() const
        return branch_;
 }
 
+static int list_id_generator = 0;
+
+BranchList::BranchList()
+       : separator_(from_ascii("|")), id_(++list_id_generator) {}
+
 
 void Branch::setBranch(docstring const & s)
 {
index 7ff833650d6adb20f6b1cb1fb325a4a3946cc8fc..bd32c4db4a625e433be66c5202c41d2f2e46f3d1 100644 (file)
@@ -14,7 +14,6 @@
 
 #include "support/docstring.h"
 
-#include <cstdlib> // rand()
 #include <list>
 
 
@@ -104,7 +103,7 @@ public:
        typedef List::const_iterator const_iterator;
 
        ///
-       BranchList() : separator_(from_ascii("|")), id_(rand()) {}
+       BranchList();
 
        ///
        docstring separator() const { return separator_; }