Well, run the code in the debugger.
Code:
Starting program: /home/sc/Documents/a.out
2 3
3 4
4 5
5 6
Breakpoint 1, main () at foo.c:36
36 if ((K2[i] = (int *) realloc (K1[i],(Col+2)*(sizeof(int)))) == NULL)
(gdb) print i
$9 = 0
(gdb) print K1[i]
$10 = (int *) 0x602040
(gdb) print K2[i]
$11 = (int *) 0x602040
(gdb) # now imagine realloc returned NULL on error
(gdb) set K2[i] = 0
(gdb) # now look at K1
(gdb) print K1[i]
$12 = (int *) 0x0
(gdb) # oops!!!! bye bye the last pointer to that bit of memory.
(gdb) quit
A debugging session is active.
Inferior 1 [process 4532] will be killed.
Quit anyway? (y or n) y
Ideally, if realloc returns NULL, you should have the old pointer to hand to do something with it.
But this code just blows it away by trying to be overly clever.