139 was returned by running valgrind, not specifically from your program. 139 is generally a seg fault error. Since it's running on their busy server, I'm not surprised. However, the fact that the error occurred while check50 runs the valgrind test is enough to go on.
If you run valgrind on your program, it shows two issues, both related to the same root problem. Both lines of code that are referenced are the same:
if (newImg != NULL)
So, there appears to be an issue with the file pointer newImg. Checking the code, I found that newImg was never initialized.
File pointers, like any pointer is not initialized by default to any particular value. The file pointer will have memory allocated to the var name large enough to contain an address, but that memory will not be initialized. It will contain whatever garbage data is in that memory at the time. It's up to you to initialize it! In this case, it appears that you've assumed it would be null, so the appropriate code would be this:
FILE *newImg = NULL;
This will clean up the valgrind issues.
If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)