Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,11 @@ class Magic : public ObjectWrap {
}
if (fd == -1) {
detect_req->free_error = false;
detect_req->error_message = "Error while opening file";
magic_close(magic);
const char *error_msg = "Error while opening file";
char* copy = static_cast<char*>(malloc(strlen(error_msg) + 1));
strcpy(copy, error_msg);
detect_req->error_message = copy;
magic_close(magic);
return;
}
result = magic_descriptor(magic, fd);
Expand Down