From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Mon, 10 Jun 2024 10:12:25 +0000 (+0200) Subject: [3.12] gh-120155: Fix Coverity issue in zoneinfo load_data() (GH-120232) (#120311) X-Git-Tag: v3.12.5~241 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ff980e3f7a8fab768148cf09aad40c20e05eb126;p=thirdparty%2FPython%2Fcpython.git [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 b90bd3e5bbc136f53b24ee791824acd6b17e0d42) Co-authored-by: Victor Stinner --- diff --git a/Modules/_zoneinfo.c b/Modules/_zoneinfo.c index 8fc861624106..47e40125cf80 100644 --- a/Modules/_zoneinfo.c +++ b/Modules/_zoneinfo.c @@ -954,6 +954,7 @@ end: static int load_data(zoneinfo_state *state, PyZoneInfo_ZoneInfo *self, PyObject *file_obj) { + int rv = 0; PyObject *data_tuple = NULL; long *utcoff = NULL; @@ -1230,7 +1231,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