[KeyManager] Check value returned by g_base64_decode().
authorPawel Andruszkiewicz <p.andruszkie@samsung.com>
Tue, 9 Jun 2015 07:54:36 +0000 (09:54 +0200)
committerPawel Andruszkiewicz <p.andruszkie@samsung.com>
Tue, 9 Jun 2015 07:54:36 +0000 (09:54 +0200)
Prevent CID: 403734

[Verification] Code compiles.

Change-Id: Iace43a13f78105d43d0986c90c81d959498c3da2
Signed-off-by: Pawel Andruszkiewicz <p.andruszkie@samsung.com>
src/keymanager/keymanager_instance.cc

index b28a05c..01bfa96 100755 (executable)
@@ -134,8 +134,10 @@ CKM::RawBuffer Base64ToRawBuffer(const std::string base64) {
   gsize len = 0;
   guchar* raw_data = g_base64_decode(base64.c_str(), &len);
   CKM::RawBuffer rawBuffer;
-  rawBuffer.assign(raw_data, raw_data + len);
-  g_free(raw_data);
+  if (raw_data) {
+    rawBuffer.assign(raw_data, raw_data + len);
+    g_free(raw_data);
+  }
   return rawBuffer;
 }