Skip to content

Commit

Permalink
Fix: Potentially uninitialized local variable
Browse files Browse the repository at this point in the history
A local non-static variable of a non-class type has an undefined value before it is initialized. For example, it is incorrect to rely on an uninitialized integer to have the value `0`.

Fixed by initialize local variable after declaration.
  • Loading branch information
Kraemii committed May 22, 2023
1 parent 8ae797f commit 00741ed
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion samba/auth/gensec/gensec_krb5.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ static NTSTATUS gensec_krb5_session_key(struct gensec_security *gensec_security,
struct gensec_krb5_state *gensec_krb5_state = gensec_security->private_data;
krb5_context context = gensec_krb5_state->smb_krb5_context->krb5_context;
krb5_auth_context auth_context = gensec_krb5_state->auth_context;
krb5_keyblock *skey;
krb5_keyblock *skey = NULL;
krb5_error_code err = -1;

if (gensec_krb5_state->session_key.data) {
Expand Down
2 changes: 1 addition & 1 deletion samba/lib/ldb/common/ldb_dn.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ static bool ldb_dn_explode(struct ldb_dn *dn)
bool is_oid = false;
bool escape = false;
unsigned x;
int l;
int l = 0;

if ( ! dn || dn->invalid) return false;

Expand Down
2 changes: 1 addition & 1 deletion samba/lib/ldb/ldb_tdb/ldb_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ int ltdb_cache_load(struct ldb_module *module)
struct ldb_dn *baseinfo_dn = NULL;
struct ldb_dn *indexlist_dn = NULL;
uint64_t seq;
struct ldb_message *baseinfo;
struct ldb_message *baseinfo = NULL;

/* a very fast check to avoid extra database reads */
if (ltdb->cache != NULL &&
Expand Down
2 changes: 1 addition & 1 deletion samba/lib/stream/packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ static void packet_next_event(struct event_context *ev, struct timed_event *te,
*/
_PUBLIC_ void packet_recv(struct packet_context *pc)
{
size_t npending;
size_t npending = 0;
NTSTATUS status;
size_t nread = 0;
DATA_BLOB blob;
Expand Down

0 comments on commit 00741ed

Please sign in to comment.