Commit 1ac64069 by Rudolf

Add basic error checking

parent f5fba026
Showing with 7 additions and 3 deletions
......@@ -51,7 +51,10 @@ int encode_file(FILE *in, FILE *out)
long size = get_file_size(in);
fseek(in, 0, SEEK_SET);
tree = create_tree(in);
if (!tree)
return -1;
encode_header(&bitbuf, tree);
......@@ -84,6 +87,7 @@ int decode_file(FILE *in, FILE *out)
int main(int argc, char *argv[])
{
int ret;
const char *infile, *outfile;
bool decompress = false;
......@@ -118,11 +122,11 @@ int main(int argc, char *argv[])
}
if (decompress)
decode_file(input, output);
ret = decode_file(input, output);
else
encode_file(input, output);
ret = encode_file(input, output);
fclose(input);
fclose(output);
return 0;
return ret;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment