@@ -27,7 +27,7 @@ typedef struct {
2727
2828static MemoryItem * * * alloc_memory (int32_t needle_len , int32_t max_haystack_len ) {
2929 MemoryItem * * * ans = NULL , * * d1 = NULL , * d2 = NULL ;
30- size_t num = max_haystack_len * max_haystack_len * needle_len ;
30+ size_t num = ( size_t ) max_haystack_len * ( size_t ) max_haystack_len * needle_len ;
3131 size_t position_sz = needle_len * sizeof (int32_t );
3232 size_t sz = (num * (sizeof (MemoryItem ) + position_sz )) + (max_haystack_len * sizeof (MemoryItem * * )) + (needle_len * sizeof (MemoryItem * ));
3333 int32_t hidx , nidx , last_idx , i , j ;
@@ -85,7 +85,7 @@ typedef struct {
8585static void alloc_stack (Stack * stack , int32_t needle_len , int32_t max_haystack_len ) {
8686 StackItem * ans = NULL ;
8787 char * base = NULL ;
88- size_t num = max_haystack_len * needle_len ;
88+ size_t num = ( size_t ) max_haystack_len * needle_len ;
8989 size_t position_sz = needle_len * sizeof (int32_t );
9090 size_t sz = sizeof (StackItem ) + position_sz ;
9191 size_t i = 0 ;
@@ -416,7 +416,7 @@ Matcher_calculate_scores(Matcher *self, PyObject *args) {
416416 items = PyTuple_New (self -> item_count );
417417 positions = PyTuple_New (self -> item_count );
418418 matches = (Match * )calloc (self -> item_count , sizeof (Match ));
419- final_positions = (int32_t * ) calloc (needle_char_len * self -> item_count , sizeof (int32_t ));
419+ final_positions = (int32_t * ) calloc (( size_t ) needle_char_len * self -> item_count , sizeof (int32_t ));
420420 if (items == NULL || matches == NULL || final_positions == NULL || positions == NULL ) {PyErr_NoMemory (); goto end ;}
421421
422422 for (i = 0 ; i < self -> item_count ; i ++ ) {
0 commit comments