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

Commit 7c4258c7 authored by Josh Gao's avatar Josh Gao
Browse files

dumpstate: fix double close.

fdopen takes ownership of the fd it's given, but dump_stat_from_fd
doesn't own the fd it's passed. These APIs should probably be cleaned
up to pass a unique_fd to explicitly transfer ownership, since the
caller immediately closes the fd afterwards, but until then, just dup.

Test: mma
Change-Id: Ie3a3c1b1951d6cc712850c326ca0bcfe46155a83
parent 037b50ec
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -561,7 +561,7 @@ static int dump_stat_from_fd(const char *title __unused, const char *path, int f
    bool z;
    char *cp, *buffer = NULL;
    size_t i = 0;
    FILE *fp = fdopen(fd, "rb");
    FILE *fp = fdopen(dup(fd), "rb");
    getline(&buffer, &i, fp);
    fclose(fp);
    if (!buffer) {