Avoid signed extension of chars for build ids.
Added a unit test that fails before the change and passes afterwards.
Bug: 120606663
Test: All unit tests pass.
Change-Id: I054c7eac0c55abc3babe1d48a041f5819ad9db81
diff --git a/libunwindstack/MapInfo.cpp b/libunwindstack/MapInfo.cpp
index 9e6bcd4..89a6a79 100644
--- a/libunwindstack/MapInfo.cpp
+++ b/libunwindstack/MapInfo.cpp
@@ -320,7 +320,8 @@
}
std::string printable_build_id;
for (const char& c : raw_build_id) {
- printable_build_id += android::base::StringPrintf("%02x", c);
+ // Use %hhx to avoid sign extension on abis that have signed chars.
+ printable_build_id += android::base::StringPrintf("%02hhx", c);
}
return printable_build_id;
}