0

my program works well, images are created correctly. But when I make check50 i get this strange error expected exit code 0, not 139

:) recover.c exists.
:) recover.c compiles.
:) handles lack of forensic image
:) recovers 000.jpg correctly
:) recovers middle images correctly
:) recovers 049.jpg correctly
:( program is free of memory errors
    expected exit code 0, not 139

What does it mean 139? I even don't have return 139 anywhere in my code.

[edited to remove code per academic honesty guidelines]

1 Answer 1

1

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. ;-)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .