The load check is your
if(image == NULL) exit(0);
Your code checks whether the memory to which p and p+1 is pointing is 0. This are two bytes, so it is a 16-bit value or WORD. Normally is that done to
interpret memory to some format information. That is depending on the data format of your image. For that you must read the specifications details of SOIL_load_image.
Such code pattern is often used to identify some areas of a color and manipulate it.
Some important code is missing which is about changing p.