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

Commit 407a2195 authored by Greg Kaiser's avatar Greg Kaiser
Browse files

fastboot: Don't leak file in error case

This is probably not very significant in this standalone tool,
but makes it easier for us to find leaks in our other system
code via static analysis.

Change-Id: I4e14cadc1e53bac0848e0e0c7f531f920e43cb0a
parent 7b461063
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -599,6 +599,7 @@ static int unzip_to_file(ZipArchiveHandle zip, char* entry_name) {
    ZipEntry zip_entry;
    ZipEntry zip_entry;
    if (FindEntry(zip, zip_entry_name, &zip_entry) != 0) {
    if (FindEntry(zip, zip_entry_name, &zip_entry) != 0) {
        fprintf(stderr, "archive does not contain '%s'\n", entry_name);
        fprintf(stderr, "archive does not contain '%s'\n", entry_name);
        fclose(fp);
        return -1;
        return -1;
    }
    }


@@ -606,10 +607,12 @@ static int unzip_to_file(ZipArchiveHandle zip, char* entry_name) {
    int error = ExtractEntryToFile(zip, &zip_entry, fd);
    int error = ExtractEntryToFile(zip, &zip_entry, fd);
    if (error != 0) {
    if (error != 0) {
        fprintf(stderr, "failed to extract '%s': %s\n", entry_name, ErrorCodeString(error));
        fprintf(stderr, "failed to extract '%s': %s\n", entry_name, ErrorCodeString(error));
        fclose(fp);
        return -1;
        return -1;
    }
    }


    lseek(fd, 0, SEEK_SET);
    lseek(fd, 0, SEEK_SET);
    // TODO: We're leaking 'fp' here.
    return fd;
    return fd;
}
}