Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5799d65f authored by Greg Kaiser's avatar Greg Kaiser
Browse files

tools/bit: Avoid leak in error condition

In the unlikely event of fread() failing, we want to avoid leaking
our buffer or the file handle.

Test: Treehugger
Change-Id: I1866d00c74ad38af4559d747fee696a60464c9f0
parent fe3877f1
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -241,6 +241,8 @@ read_file(const string& filename)

    char* buf = (char*)malloc(size);
    if ((size_t) size != fread(buf, 1, size, file)) {
        free(buf);
        fclose(file);
        return string();
    }