@@ -904,7 +904,13 @@ load_data(PyZoneInfo_ZoneInfo *self, PyObject *file_obj)
904
904
// Load the transition indices and list
905
905
self -> trans_list_utc =
906
906
PyMem_Malloc (self -> num_transitions * sizeof (int64_t ));
907
+ if (self -> trans_list_utc == NULL ) {
908
+ goto error ;
909
+ }
907
910
trans_idx = PyMem_Malloc (self -> num_transitions * sizeof (Py_ssize_t ));
911
+ if (trans_idx == NULL ) {
912
+ goto error ;
913
+ }
908
914
909
915
for (size_t i = 0 ; i < self -> num_transitions ; ++ i ) {
910
916
PyObject * num = PyTuple_GetItem (trans_utc , i );
@@ -986,6 +992,9 @@ load_data(PyZoneInfo_ZoneInfo *self, PyObject *file_obj)
986
992
987
993
// Build _ttinfo objects from utcoff, dstoff and abbr
988
994
self -> _ttinfos = PyMem_Malloc (self -> num_ttinfos * sizeof (_ttinfo ));
995
+ if (self -> _ttinfos == NULL ) {
996
+ goto error ;
997
+ }
989
998
for (size_t i = 0 ; i < self -> num_ttinfos ; ++ i ) {
990
999
PyObject * tzname = PyTuple_GetItem (abbr , i );
991
1000
if (tzname == NULL ) {
@@ -1001,6 +1010,9 @@ load_data(PyZoneInfo_ZoneInfo *self, PyObject *file_obj)
1001
1010
// Build our mapping from transition to the ttinfo that applies
1002
1011
self -> trans_ttinfos =
1003
1012
PyMem_Calloc (self -> num_transitions , sizeof (_ttinfo * ));
1013
+ if (self -> trans_ttinfos == NULL ) {
1014
+ goto error ;
1015
+ }
1004
1016
for (size_t i = 0 ; i < self -> num_transitions ; ++ i ) {
1005
1017
size_t ttinfo_idx = trans_idx [i ];
1006
1018
assert (ttinfo_idx < self -> num_ttinfos );
0 commit comments