mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-20 07:49:43 +02:00
#2631 Adding safeguard to the while loops
This commit is contained in:
@@ -17,7 +17,9 @@ function getId() {
|
||||
*/
|
||||
function isfastforwardable(currentCommit, otherCommit) {
|
||||
log.debug('Entering isfastforwardable:', currentCommit.id, otherCommit.id);
|
||||
while (currentCommit.seq <= otherCommit.seq && currentCommit !== otherCommit) {
|
||||
let cnt = 0;
|
||||
while (currentCommit.seq <= otherCommit.seq && currentCommit !== otherCommit && cnt < 1000) {
|
||||
cnt++;
|
||||
// only if other branch has more commits
|
||||
if (otherCommit.parent == null) break;
|
||||
if (Array.isArray(otherCommit.parent)) {
|
||||
|
@@ -227,7 +227,9 @@ function renderCommitHistory(svg, commitid, branches, direction) {
|
||||
let commit;
|
||||
const numCommits = Object.keys(allCommitsDict).length;
|
||||
if (typeof commitid === 'string') {
|
||||
let cnt = 0;
|
||||
do {
|
||||
cnt++;
|
||||
commit = allCommitsDict[commitid];
|
||||
log.debug('in renderCommitHistory', commit.id, commit.seq);
|
||||
if (svg.select('#node-' + commitid).size() > 0) {
|
||||
@@ -293,7 +295,7 @@ function renderCommitHistory(svg, commitid, branches, direction) {
|
||||
.text(', ' + commit.message);
|
||||
}
|
||||
commitid = commit.parent;
|
||||
} while (commitid && allCommitsDict[commitid]);
|
||||
} while (commitid && allCommitsDict[commitid] && cnt < 1000);
|
||||
}
|
||||
|
||||
if (Array.isArray(commitid)) {
|
||||
@@ -313,7 +315,9 @@ function renderCommitHistory(svg, commitid, branches, direction) {
|
||||
*/
|
||||
function renderLines(svg, commit, direction, branchColor) {
|
||||
branchColor = branchColor || 0;
|
||||
while (commit.seq > 0 && !commit.lineDrawn) {
|
||||
let cnt = 0;
|
||||
while (commit.seq > 0 && !commit.lineDrawn && cnt < 1000) {
|
||||
cnt++;
|
||||
if (typeof commit.parent === 'string') {
|
||||
svgDrawLineForCommits(svg, commit.id, commit.parent, direction, branchColor);
|
||||
commit.lineDrawn = true;
|
||||
|
Reference in New Issue
Block a user