Calloc function tries to allocate 4096 bytes. If such memory is not available, it returns NULL pointer. This exception was not handled in the code, causing a dirty crash.