Skip to content

Commit

Permalink
Merge pull request #157 from ijsf/fix/binary
Browse files Browse the repository at this point in the history
fix: Use binary fopen where necessary
  • Loading branch information
tyfkda authored May 26, 2024
2 parents 26ee984 + 44a7a4a commit 934809e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/ld/elfobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void elfobj_init(ElfObj *elfobj) {

bool open_elf(const char *fn, ElfObj *elfobj) {
FILE *fp;
if (!is_file(fn) || (fp = fopen(fn, "r")) == NULL) {
if (!is_file(fn) || (fp = fopen(fn, "rb")) == NULL) {
fprintf(stderr, "cannot open: %s\n", fn);
} else {
if (read_elf(elfobj, fp, fn))
Expand Down
2 changes: 1 addition & 1 deletion src/util/archive.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ static uint32_t read4be(FILE *fp) {

Archive *load_archive(const char *filename) {
FILE *fp;
if (!is_file(filename) || (fp = fopen(filename, "r")) == NULL)
if (!is_file(filename) || (fp = fopen(filename, "rb")) == NULL)
return NULL;

Archive *ar = malloc_or_die(sizeof(*ar));
Expand Down
2 changes: 1 addition & 1 deletion src/wcc/wasm_linker.c
Original file line number Diff line number Diff line change
Expand Up @@ -1423,7 +1423,7 @@ bool read_wasm_obj(WasmLinker *linker, const char *filename) {
char *ext = get_ext(filename);
if (strcasecmp(ext, "o") == 0) {
FILE *fp;
if (!is_file(filename) || (fp = fopen(filename, "r")) == NULL) {
if (!is_file(filename) || (fp = fopen(filename, "rb")) == NULL) {
fprintf(stderr, "cannot open: %s\n", filename);
return false;
}
Expand Down

0 comments on commit 934809e

Please sign in to comment.