Issue in the code

I am trying to implement a problem where a matrix consisting of 0s and 1s are given and i have to insert a block of 1s with its count value in a set.
For eg
1 0 1 0 0 0
1 1 1 0 0 0
0 0 0 1 1 1
there are 2 block of 1s.
one at top left having (0,0) (1,0) (1,1) (1,2) (0,2)
and another at bottom right.
So these blocks can be traversed via dfs.
But when i am trying to implement it via dfs,i am facing segmentation fault.


Infect variable in the code denotes that any 0 in the neighbourhood of 1 can become 1 if infect is 1 and then count will be returned.

So, I hope this is not related to Kosaraju’s Algo. or am I missing something?

What is that you want me to do? Tell the approach or something?