Skip to content

quickmer count seg faults if .qm file is missing #3

@dgordon562

Description

@dgordon562

It took me a while to track down why it was seg faulting, but a look at the code makes it clear:

337 FILE * Hash_file = fopen(path, "r");
338 FILE * fasta_input = fopen(argv[argc-2], "r");
339 if (!fasta_input) {
340 puts("Input open fail");
341 }
342 strcpy(path, argv[argc-1]);
343 strcat(path, ".bin");
344 FILE * OutFile = fopen(path, "w");
345 fseek(Hash_file, 4, 0);

So if "path" doesn't exist, Hash_file is a null pointer and fseek(Hash_file, 4, 0 ) will seg fault.
It would be helpful to users if you checked to see if Hash_file is null and gave an informative error message.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions