Fix bugs
authorHyunho Kang <hhstark.kang@samsung.com>
Thu, 16 Mar 2017 10:52:29 +0000 (19:52 +0900)
committerHyunho Kang <hhstark.kang@samsung.com>
Thu, 16 Mar 2017 10:57:33 +0000 (19:57 +0900)
- Handle leak
- Deref after null

Change-Id: I5bd6f60da90000c11f1bf8457cf391d017d8a902
Signed-off-by: Hyunho Kang <hhstark.kang@samsung.com>
src/Tizen.Applications.DataControl/Tizen.Applications.DataControl/MatrixCursor.cs
src/Tizen.Applications.DataControl/Tizen.Applications.DataControl/Provider.cs

index 685a554..c0d8047 100755 (executable)
@@ -260,6 +260,10 @@ namespace Tizen.Applications.DataControl
             }
 
             byte_array = GetValue(index);
+            if (byte_array == null)
+            {
+                ErrorFactory.ThrowException(ResultType.InvalidParamer, false);
+            }
             ret = BitConverter.ToInt32(byte_array, 0);
 
             return ret;
@@ -280,6 +284,10 @@ namespace Tizen.Applications.DataControl
             }
 
             byte_array = GetValue(index);
+            if (byte_array == null)
+            {
+                ErrorFactory.ThrowException(ResultType.InvalidParamer, false);
+            }
             ret = BitConverter.ToInt64(byte_array, 0);
 
             return ret;
@@ -300,6 +308,10 @@ namespace Tizen.Applications.DataControl
             }
 
             byte_array = GetValue(index);
+            if (byte_array == null)
+            {
+                ErrorFactory.ThrowException(ResultType.InvalidParamer, false);
+            }
             ret = BitConverter.ToDouble(byte_array, 0);
 
             return ret;
index b2bc00c..699f522 100755 (executable)
@@ -119,7 +119,7 @@ namespace Tizen.Applications.DataControl
             {
                 query += " LIMIT " + countPerPage + " OFFSET " + (countPerPage * (pageNum - 1));
             }
-
+            handle.Dispose();
             return query;
         }
 
@@ -461,14 +461,15 @@ namespace Tizen.Applications.DataControl
                                 if (ret != ResultType.Success)
                                 {
                                     Log.Error(LogTag, "Writing a row to a file descriptor is failed");
+                                    mc.Dispose();
                                     return;
                                 }
                             }
                         }
                         while (write_size > 0);
+                        mc.Dispose();
                     }
 
-                    mc.Dispose();
                 }
                 else
                 {
@@ -806,6 +807,7 @@ namespace Tizen.Applications.DataControl
                 default:
                     break;
             }
+            handle.Dispose();
 
             return query;
         }
@@ -822,6 +824,7 @@ namespace Tizen.Applications.DataControl
                 provider = _providerDict[dataID];
                 provider._nativeHandle = handlePtr;
             }
+            handle.Dispose();
 
             return provider;
         }
@@ -839,7 +842,7 @@ namespace Tizen.Applications.DataControl
         {
             ResultType ret;
 
-            if (changedData == null | changedData.SafeBundleHandle.IsInvalid)
+            if (changedData == null || changedData.SafeBundleHandle.IsInvalid)
             {
                 ErrorFactory.ThrowException(ResultType.InvalidParamer, false, "changedData");
             }