Skip to content

Commit b90bd3e

Browse files
authored
gh-120155: Fix Coverity issue in zoneinfo load_data() (#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|
1 parent 4829522 commit b90bd3e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: Modules/_zoneinfo.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,7 @@ ttinfo_eq(const _ttinfo *const tti0, const _ttinfo *const tti1)
944944
static int
945945
load_data(zoneinfo_state *state, PyZoneInfo_ZoneInfo *self, PyObject *file_obj)
946946
{
947+
int rv = 0;
947948
PyObject *data_tuple = NULL;
948949

949950
long *utcoff = NULL;
@@ -1220,7 +1221,6 @@ load_data(zoneinfo_state *state, PyZoneInfo_ZoneInfo *self, PyObject *file_obj)
12201221
}
12211222
}
12221223

1223-
int rv = 0;
12241224
goto cleanup;
12251225
error:
12261226
// These resources only need to be freed if we have failed, if we succeed

0 commit comments

Comments
 (0)