Skip to content

Commit

Permalink
close file descriptor only if >=0
Browse files Browse the repository at this point in the history
  • Loading branch information
embetrix committed Jan 30, 2025
1 parent 3939425 commit 3ddc405
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion bmap-writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,9 @@ int main(int argc, char *argv[]) {
std::cerr << "Failed to write image to device: " << device << std::endl;
}

close(image_fd);
if (image_fd >= 0) {
close(image_fd);
}

return ret;
}

0 comments on commit 3ddc405

Please sign in to comment.