加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-Fix-a-couple-small-static-analysis-findings-for-uninitialized-structs.patch 2.12 KB
一键复制 编辑 原始数据 按行查看 历史
From 2c4ee52a948a9ccff2242cd02ac8ce81a0559deb Mon Sep 17 00:00:00 2001
From: David Cantrell <dcantrell@redhat.com>
Date: Tue, 26 Mar 2024 12:13:55 -0400
Subject: [PATCH] Fix a couple small static analysis findings for uninitialized
structs
The memset() on the KeyValue is more explicit even though if you trace
the code you will see it fills out the struct. However, it's possible
that not every struct member will be initialized and adding the
memset() makes things more obvious and appeases the static analyzer.
Conflict:NA
Reference:https://github.com/openSUSE/libsolv/commit/2c4ee52a948a9ccff2242cd02ac8ce81a0559deb.patch
---
ext/repo_rpmmd.c | 2 ++
ext/repo_susetags.c | 1 +
ext/testcase.c | 3 +++
3 files changed, 6 insertions(+)
diff --git a/ext/repo_rpmmd.c b/ext/repo_rpmmd.c
index 1232e43..5d0f5fe 100644
--- a/ext/repo_rpmmd.c
+++ b/ext/repo_rpmmd.c
@@ -609,6 +609,8 @@ fill_cshash_from_new_solvables(struct parsedata *pd)
KeyValue kv;
Repokey *key;
+ memset(&kv, 0, sizeof(kv));
+
for (i = pd->first; i < pool->nsolvables; i++)
{
if (pool->solvables[i].repo != pd->repo)
diff --git a/ext/repo_susetags.c b/ext/repo_susetags.c
index dc60aa4..86bb1e9 100644
--- a/ext/repo_susetags.c
+++ b/ext/repo_susetags.c
@@ -339,6 +339,7 @@ lookup_shared_id(Repodata *data, Id p, Id keyname, Id voidid, int uninternalized
if (uninternalized)
{
KeyValue kv;
+ memset(&kv, 0, sizeof(kv));
Repokey *key = repodata_lookup_kv_uninternalized(data, p, keyname, &kv);
if (!key)
return 0;
diff --git a/ext/testcase.c b/ext/testcase.c
index f46f738..3e22546 100644
--- a/ext/testcase.c
+++ b/ext/testcase.c
@@ -1440,6 +1440,7 @@ testcase_solverresult(Solver *solv, int resultflags)
{
Queue q;
+
queue_init(&q);
solver_get_orphaned(solv, &q);
for (i = 0; i < q.count; i++)
@@ -1497,6 +1498,8 @@ testcase_solverresult(Solver *solv, int resultflags)
if ((resultflags & TESTCASE_RESULT_USERINSTALLED) != 0)
{
Queue q;
+
+ queue_init(&q);
solver_get_userinstalled(solv, &q, 0);
for (i = 0; i < q.count; i++)
{
--
2.9.3.windows.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化