Skip to content

Commit

Permalink
gh-120155: Fix Coverity issue in zoneinfo load_data() (#120232)
Browse files Browse the repository at this point in the history
Declare the 'rv' varaible at the top of the load_data() function to
make sure that it's initialized before the first 'goto error' which
uses 'rv' (return rv).

Fix the Coverity issue:

Error: UNINIT (CWE-457):
Python-3.12.2/Modules/_zoneinfo.c:1233:5: skipped_decl: Jumping over declaration of ""rv"".
Python-3.12.2/Modules/_zoneinfo.c:1284:5: uninit_use: Using uninitialized value ""rv"".
  1282|       }
  1283|
  1284|->     return rv;
  1285|   }
  1286|
  • Loading branch information
vstinner committed Jun 10, 2024
1 parent 4829522 commit b90bd3e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Modules/_zoneinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,7 @@ ttinfo_eq(const _ttinfo *const tti0, const _ttinfo *const tti1)
static int
load_data(zoneinfo_state *state, PyZoneInfo_ZoneInfo *self, PyObject *file_obj)
{
int rv = 0;
PyObject *data_tuple = NULL;

long *utcoff = NULL;
Expand Down Expand Up @@ -1220,7 +1221,6 @@ load_data(zoneinfo_state *state, PyZoneInfo_ZoneInfo *self, PyObject *file_obj)
}
}

int rv = 0;
goto cleanup;
error:
// These resources only need to be freed if we have failed, if we succeed
Expand Down

0 comments on commit b90bd3e

Please sign in to comment.