From f101236657437d5f148ef0ecbe7c33a8eac1ee5a Mon Sep 17 00:00:00 2001 From: Roman Kiryanov Date: Thu, 26 Jul 2018 13:41:14 -0700 Subject: [PATCH] Do not crash if secontext is nullptr LOG(DEBUG) tries to print a string pointed by secontext.get() but crashed if it was nullptr. Bug: 111888637 Test: "make -j50" and ran emulator Change-Id: Iac78f650e7f48781030dc610f7d35cd52c250802 Signed-off-by: Roman Kiryanov --- vold_prepare_subdirs.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vold_prepare_subdirs.cpp b/vold_prepare_subdirs.cpp index 1b466e9..8c3df30 100644 --- a/vold_prepare_subdirs.cpp +++ b/vold_prepare_subdirs.cpp @@ -63,7 +63,8 @@ static bool prepare_dir(struct selabel_handle* sehandle, mode_t mode, uid_t uid, secontext.reset(tmp_secontext); } LOG(DEBUG) << "Setting up mode " << std::oct << mode << std::dec << " uid " << uid << " gid " - << gid << " context " << secontext.get() << " on path: " << path; + << gid << " context " << (secontext ? secontext.get() : "null") + << " on path: " << path; if (secontext) { if (setfscreatecon(secontext.get()) != 0) { PLOG(ERROR) << "Unable to read setfscreatecon for: " << path;