nuplayer2: Fix two use-after-frees
- std::ostringstream::c_str returns a string by value, so we can't
immediately call c_str() on it and assign that to a variable.
- DrmUUID::arrayToHex returns a String8 by value. Similar "can't just
call string() and assign that to a variable".
Both caught by our static analyzer.
Bug: None
Test: Ran the analyzer again
Change-Id: Ia9e0b2b00ee5150225dd487f3611a3893946fa4b
diff --git a/media/libmediaplayer2/nuplayer2/NuPlayer2Drm.cpp b/media/libmediaplayer2/nuplayer2/NuPlayer2Drm.cpp
index 4853ae1..0e096b0 100644
--- a/media/libmediaplayer2/nuplayer2/NuPlayer2Drm.cpp
+++ b/media/libmediaplayer2/nuplayer2/NuPlayer2Drm.cpp
@@ -148,9 +148,10 @@
}
uint32_t psshSize = pssh.tellp();
- const uint8_t* psshPtr = reinterpret_cast<const uint8_t*>(pssh.str().c_str());
- const char *psshHex = DrmUUID::arrayToHex(psshPtr, psshSize).string();
- ALOGV("retrieveDrmInfo: MEDIA_DRM_INFO PSSH: size: %u %s", psshSize, psshHex);
+ std::string psshBase = pssh.str();
+ const auto* psshPtr = reinterpret_cast<const uint8_t*>(psshBase.c_str());
+ ALOGV("retrieveDrmInfo: MEDIA_DRM_INFO PSSH: size: %u %s", psshSize,
+ DrmUUID::arrayToHex(psshPtr, psshSize).string());
// 1) Write PSSH bytes
drmInfo.write(reinterpret_cast<const char *>(&psshSize), sizeof(psshSize));