Fix arrays in kvjson visitor, prohibit empty db name 11/33811/1
authorPiotr Bartosiewicz <p.bartosiewi@partner.samsung.com>
Thu, 15 Jan 2015 09:13:33 +0000 (10:13 +0100)
committerPiotr Bartosiewicz <p.bartosiewi@partner.samsung.com>
Thu, 15 Jan 2015 09:13:33 +0000 (10:13 +0100)
[Bug/Feature]   Arrays were not correctly handled.
[Cause]         N/A
[Solution]      N/A
[Verification]  Build, run tests

Change-Id: Idd5c2c35baf602e09961ee8af80857dda313a5da

src/config/from-kvjson-visitor.hpp
src/config/sqlite3/connection.cpp

index 174bbad..bbae07e 100644 (file)
@@ -111,11 +111,10 @@ private:
 
     int getArraySize(std::string& name, json_object* object)
     {
-        int length = -1, jlength = json_object_array_length(object);
         if (mStorePtr->exists(name)) {
-            length = mStorePtr->get<int>(name);
+            return mStorePtr->get<int>(name);
         }
-        return length != jlength ? jlength : length;
+        return json_object_array_length(object);
     }
 
     template<typename T>
index e5d0552..cb25694 100644 (file)
@@ -31,6 +31,11 @@ namespace sqlite3 {
 
 Connection::Connection(const std::string& path)
 {
+    if (path.empty()) {
+        // Sqlite creates temporary database in case of empty path
+        // but we want to forbid this.
+        throw ConfigException("Error opening the database: empty path");
+    }
     if (::sqlite3_open_v2(path.c_str(),
                           &mDbPtr,
                           SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,