LayerStats: Fix a use-after-free
std::string::c_str returns memory that's freed when the string dies. So,
this method should be returning the string, rather than a pointer to
it's freshly-deleted contents.
Caught by our static analyzer.
Bug: None
Test: Builds
Change-Id: I3dce7b60c6cfb4e3bfbd6c0dd6fe30dfe7f4313c
diff --git a/services/surfaceflinger/LayerStats.h b/services/surfaceflinger/LayerStats.h
index 7a190fd..bd17d82 100644
--- a/services/surfaceflinger/LayerStats.h
+++ b/services/surfaceflinger/LayerStats.h
@@ -50,7 +50,7 @@
// Return the name of the composition type
static const char* layerCompositionType(int32_t compositionType);
// Return the name of the pixel format
- static const char* layerPixelFormat(int32_t pixelFormat);
+ static std::string layerPixelFormat(int32_t pixelFormat);
// Calculate scale ratios of layer's width/height with rotation information
static std::string scaleRatioWH(const LayerProtoParser::Layer* layer);
// Calculate scale ratio from source to destination and convert to string