@@ -909,7 +909,13 @@ load_data(PyZoneInfo_ZoneInfo *self, PyObject *file_obj)
909
909
// Load the transition indices and list
910
910
self -> trans_list_utc =
911
911
PyMem_Malloc (self -> num_transitions * sizeof (int64_t ));
912
+ if (self -> trans_list_utc == NULL ) {
913
+ goto error ;
914
+ }
912
915
trans_idx = PyMem_Malloc (self -> num_transitions * sizeof (Py_ssize_t ));
916
+ if (trans_idx == NULL ) {
917
+ goto error ;
918
+ }
913
919
914
920
for (size_t i = 0 ; i < self -> num_transitions ; ++ i ) {
915
921
PyObject * num = PyTuple_GetItem (trans_utc , i );
@@ -991,6 +997,9 @@ load_data(PyZoneInfo_ZoneInfo *self, PyObject *file_obj)
991
997
992
998
// Build _ttinfo objects from utcoff, dstoff and abbr
993
999
self -> _ttinfos = PyMem_Malloc (self -> num_ttinfos * sizeof (_ttinfo ));
1000
+ if (self -> _ttinfos == NULL ) {
1001
+ goto error ;
1002
+ }
994
1003
for (size_t i = 0 ; i < self -> num_ttinfos ; ++ i ) {
995
1004
PyObject * tzname = PyTuple_GetItem (abbr , i );
996
1005
if (tzname == NULL ) {
@@ -1006,6 +1015,9 @@ load_data(PyZoneInfo_ZoneInfo *self, PyObject *file_obj)
1006
1015
// Build our mapping from transition to the ttinfo that applies
1007
1016
self -> trans_ttinfos =
1008
1017
PyMem_Calloc (self -> num_transitions , sizeof (_ttinfo * ));
1018
+ if (self -> trans_ttinfos == NULL ) {
1019
+ goto error ;
1020
+ }
1009
1021
for (size_t i = 0 ; i < self -> num_transitions ; ++ i ) {
1010
1022
size_t ttinfo_idx = trans_idx [i ];
1011
1023
assert (ttinfo_idx < self -> num_ttinfos );
0 commit comments