From d44063c4b7509b008ed44621a870e7bd309e0bea Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Fri, 9 Sep 2016 13:48:30 +0900 Subject: [PATCH] Fix null pointer dereference issue Change-Id: I4832409e95a1766eae921917cf4910bb5ca00981 Signed-off-by: Sangyoon Jang --- src/pkg_initdb/pkg_initdb.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pkg_initdb/pkg_initdb.cc b/src/pkg_initdb/pkg_initdb.cc index edf0129..1bedda5 100644 --- a/src/pkg_initdb/pkg_initdb.cc +++ b/src/pkg_initdb/pkg_initdb.cc @@ -88,6 +88,10 @@ void InitdbLoadDirectory(uid_t uid, const bf::path& directory, bool preload) { void RemoveOldDatabases(uid_t uid) { char *parser_db = getUserPkgParserDBPathUID(uid); char *cert_db = getUserPkgCertDBPathUID(uid); + if (parser_db == nullptr || cert_db == nullptr) { + std::cerr << "Failed to get db path, cannot remove old databases"; + return; + } std::string journal = "-journal"; std::string parser_db_journal = parser_db + journal; std::string cert_db_journal = cert_db + journal; -- 2.7.4