Skip to content

Commit

Permalink
fix: potentially uninitialized variables
Browse files Browse the repository at this point in the history
Signed-off-by: Federico Aponte <[email protected]>
  • Loading branch information
federico-sysdig authored and poiana committed Dec 6, 2023
1 parent 2809baf commit 6509c8e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
3 changes: 1 addition & 2 deletions test/libscap/test_suites/engines/gvisor/gvisor_parsers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,11 +405,10 @@ TEST(gvisor_parsers, small_buffer)

TEST(gvisor_parsers, procfs_entry)
{
scap_gvisor::parsers::procfs_result res;
std::string not_json = "not a json string";
std::string sandbox_id = "deadbeef";

res = scap_gvisor::parsers::parse_procfs_json(not_json, sandbox_id);
scap_gvisor::parsers::procfs_result res = scap_gvisor::parsers::parse_procfs_json(not_json, sandbox_id);
EXPECT_EQ(res.status, SCAP_FAILURE);

std::string json = R"(
Expand Down
4 changes: 2 additions & 2 deletions userspace/libscap/engine/gvisor/gvisor.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ struct parse_result {
// description of the error in case of failure
std::string error;
// the total encoded event(s) size
size_t size;
size_t size = 0;
// pointers to each encoded event within the supplied output buffer
std::vector<scap_evt*> scap_events;
// number of events dropped by gVisor
uint32_t dropped_count;
uint32_t dropped_count = 0;
};

struct procfs_result {
Expand Down
1 change: 1 addition & 0 deletions userspace/libscap/engine/gvisor/parsers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2135,6 +2135,7 @@ parse_result parse_gvisor_proto(scap_const_sized_buffer gvisor_buf, scap_sized_b
procfs_result parse_procfs_json(const std::string &input, const std::string &sandbox)
{
procfs_result res;
memset(&res.tinfo, 0, sizeof(res.tinfo));
Json::Value root;
Json::CharReaderBuilder builder;
std::string err;
Expand Down

0 comments on commit 6509c8e

Please sign in to comment.