From 1f403670eb789138bba809ec112ce139b4f3a051 Mon Sep 17 00:00:00 2001 From: ItaloCobains Date: Tue, 14 Nov 2023 09:19:24 -0300 Subject: [PATCH] Fix code scanning alert - Returning stack-allocated memory bug --- package-lock.json | 4 ++-- package.json | 2 +- src/graph.cc | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index ca1d511..3cf1673 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@italocobains/graph", - "version": "1.0.8", + "version": "1.1.8", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@italocobains/graph", - "version": "1.0.8", + "version": "1.1.8", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index a4463c3..6cdecea 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@italocobains/graph", - "version": "1.1.8", + "version": "1.1.9", "description": "This is a lib write by c++ and nodejs addon api for graph algorithm.", "main": "index.js", "scripts": { diff --git a/src/graph.cc b/src/graph.cc index 71bb87c..75ed157 100644 --- a/src/graph.cc +++ b/src/graph.cc @@ -139,7 +139,8 @@ Edge *Graph::getEdge(int sourceId, int targetId) const { if (edge.sourceId == sourceId && edge.targetId == targetId) { - return &edge; + Edge *edgeCopy = new Edge(edge); + return edgeCopy; } } return nullptr;