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.
---
 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-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to