Commit 0b2918d4a14e8a9ed83406d89624ae2442ec20b7
Committed by
guoyin.chen
1 parent
58b76def49
Exists in
smarc-imx_v2015.04_4.1.15_1.0.0_ga
and in
1 other branch
MLK-12199 common:env fix unintialized scalar value
Reported by coverity ID: 17900 17902 Using uninitialized value e. Field e.flags is uninitialized when calling hsearch_r Signed-off-by: Peng Fan <peng.fan@nxp.com>
Showing 3 changed files with 11 additions and 1 deletions Side-by-side Diff
common/cmd_nvedit.c
... | ... | @@ -5,7 +5,7 @@ |
5 | 5 | * (C) Copyright 2001 Sysgo Real-Time Solutions, GmbH <www.elinos.com> |
6 | 6 | * Andreas Heppel <aheppel@sysgo.de> |
7 | 7 | * |
8 | - * Copyright 2011-2014 Freescale Semiconductor, Inc. | |
8 | + * Copyright (C) 2011-2016 Freescale Semiconductor, Inc. | |
9 | 9 | * |
10 | 10 | * SPDX-License-Identifier: GPL-2.0+ |
11 | 11 | */ |
... | ... | @@ -90,6 +90,8 @@ |
90 | 90 | |
91 | 91 | e.key = name; |
92 | 92 | e.data = NULL; |
93 | + e.callback = NULL; | |
94 | + e.flags = 0; | |
93 | 95 | hsearch_r(e, FIND, &ep, &env_htab, flag); |
94 | 96 | if (ep == NULL) |
95 | 97 | return 0; |
... | ... | @@ -271,6 +273,8 @@ |
271 | 273 | |
272 | 274 | e.key = name; |
273 | 275 | e.data = value; |
276 | + e.callback = NULL; | |
277 | + e.flags = 0; | |
274 | 278 | hsearch_r(e, ENTER, &ep, &env_htab, env_flag); |
275 | 279 | free(value); |
276 | 280 | if (!ep) { |
... | ... | @@ -615,6 +619,8 @@ |
615 | 619 | |
616 | 620 | e.key = name; |
617 | 621 | e.data = NULL; |
622 | + e.callback = NULL; | |
623 | + e.flags = 0; | |
618 | 624 | hsearch_r(e, FIND, &ep, &env_htab, 0); |
619 | 625 | |
620 | 626 | return ep ? ep->data : NULL; |
... | ... | @@ -1089,6 +1095,8 @@ |
1089 | 1095 | |
1090 | 1096 | e.key = argv[1]; |
1091 | 1097 | e.data = NULL; |
1098 | + e.callback = NULL; | |
1099 | + e.flags = 0; | |
1092 | 1100 | hsearch_r(e, FIND, &ep, &env_htab, 0); |
1093 | 1101 | |
1094 | 1102 | return (ep == NULL) ? 1 : 0; |
common/env_callback.c