aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin ROBIN <dev@benjarobin.fr>2024-01-14 18:17:01 +0100
committerYordan Karadzhov <y.karadz@gmail.com>2024-01-20 13:14:08 +0200
commit4b6571c1d7c91d938b4f97898370204eb6f7c59c (patch)
tree9d08a0adb3093dcdaf7af0fc161c56f4815bf360
parent982a3157c09b413a4658fbe716f77ff4811e7c80 (diff)
downloadkernel-shark-4b6571c1d7c91d938b4f97898370204eb6f7c59c.tar.gz
kernelshark: Fix potential access to uninitialized variable
If "nStreams" is zero, jstream may be accessed while uninitialized in KsSession::_savePlots() and in KsSession::_getPlots() Signed-off-by: Benjamin ROBIN <dev@benjarobin.fr> Signed-off-by: Yordan Karadzhov <y.karadz@gmail.com>
-rw-r--r--src/KsSession.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/KsSession.cpp b/src/KsSession.cpp
index b9edb3a2..af862812 100644
--- a/src/KsSession.cpp
+++ b/src/KsSession.cpp
@@ -348,7 +348,7 @@ void KsSession::loadGraphs(kshark_context *kshark_ctx,
void KsSession::_savePlots(int sd, KsGLWidget *glw, bool cpu)
{
kshark_config_doc *streamsConf = kshark_config_alloc(KS_CONFIG_JSON);
- json_object *jallStreams, *jstream, *jstreamId, *jplots;
+ json_object *jallStreams, *jstream = nullptr, *jstreamId, *jplots;
QVector<int> plotIds;
int nStreams;
@@ -438,7 +438,7 @@ void KsSession::_saveComboPlots(KsGLWidget *glw)
QVector<int> KsSession::_getPlots(int sd, bool cpu)
{
kshark_config_doc *streamsConf = kshark_config_alloc(KS_CONFIG_JSON);
- json_object *jallStreams, *jstream, *jstreamId, *jplots;
+ json_object *jallStreams, *jstream = nullptr, *jstreamId, *jplots;
int nStreams, nPlots, id;
const char *plotKey;
QVector<int> plots;