Le 13/09/2024 à 11:11, Jean-Marc Lasgouttes a écrit :
commit 9f40eaee15d53ce418a728d3ff3716541d35775f
Author: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date: Fri Sep 13 11:07:05 2024 +0200
Do not use rand() to set a BranchList id
Use a simple counting instead, beecause Coverity complains that rand()
is not safe, and counting is siimpler anyway.
Jürgen, could you double-check this?
JMarc
---
src/BranchList.cpp | 5 +++++
src/BranchList.h | 3 +--
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/BranchList.cpp b/src/BranchList.cpp
index fc61065a4b..37e746293d 100644
--- a/src/BranchList.cpp
+++ b/src/BranchList.cpp
@@ -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)
{
diff --git a/src/BranchList.h b/src/BranchList.h
index 7ff833650d..bd32c4db4a 100644
--- a/src/BranchList.h
+++ b/src/BranchList.h
@@ -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_; }
--
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel