Skip to content

Commit ff980e3

Browse files
[3.12] gh-120155: Fix Coverity issue in zoneinfo load_data() (GH-120232) (#120311)
gh-120155: Fix Coverity issue in zoneinfo load_data() (GH-120232) 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| (cherry picked from commit b90bd3e) Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent 82c93ea commit ff980e3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Modules/_zoneinfo.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,7 @@ ttinfo_eq(const _ttinfo *const tti0, const _ttinfo *const tti1)
954954
static int
955955
load_data(zoneinfo_state *state, PyZoneInfo_ZoneInfo *self, PyObject *file_obj)
956956
{
957+
int rv = 0;
957958
PyObject *data_tuple = NULL;
958959

959960
long *utcoff = NULL;
@@ -1230,7 +1231,6 @@ load_data(zoneinfo_state *state, PyZoneInfo_ZoneInfo *self, PyObject *file_obj)
12301231
}
12311232
}
12321233

1233-
int rv = 0;
12341234
goto cleanup;
12351235
error:
12361236
// These resources only need to be freed if we have failed, if we succeed

0 commit comments

Comments
 (0)