summaryrefslogtreecommitdiff
path: root/libs/androidfw/AssetsProvider.cpp
diff options
context:
space:
mode:
author Lee Shombert <shombert@google.com> 2024-12-03 12:49:01 -0800
committer Lee Shombert <shombert@google.com> 2024-12-03 21:40:01 +0000
commit8f4be0294d89e745be4b6b9add263932b8235f6e (patch)
tree6518339fbb73605b0c6e0534eb56d4be01144003 /libs/androidfw/AssetsProvider.cpp
parentdde612297a95746beaefe205afc1d55795f43eb1 (diff)
Fix error handling in CursorWindow
If a CursorWindow is created from a Parcel but the file descriptor is invalid or the mmap() call fails, the CursorWindow destructor will be invoked with an inconsistent object. The destructor will attempt to call munmap() with an unconfigured mData attribute. This makes two changes. First, the destructor only attempts to unmap memory if the file descriptor is non-negative. The old code unmapped memory if the file descriptor was not -1. However, the construction code treated any negative file descriptor as an error. Second, when a CursorWindow is created from a parcel, the file descriptor field is not changed from -1 (the constructor default) until it is known that the memory mapping has succeeded. If the function exits early, it is no longer in a half-constructed state. As a bonus, if mmap() fails in the method, the duplicated file descriptor is closed rather than leaked. Flag: EXEMPT bug-fix Bug: 330108840 Test: atest * libandroidfw_tests Change-Id: I94a9240dbd06b255bff9491ea390b485bac3cb88
Diffstat (limited to 'libs/androidfw/AssetsProvider.cpp')
0 files changed, 0 insertions, 0 deletions