BugID:17657735:[HAL ubuntu] fix mm leak in HAL_KV
@@ -630,6 +630,7 @@ static kv_file_t *kvfile = NULL;
int HAL_Kv_Set(const char *key, const void *val, int len, int sync)
{
+ int ret;
if (!kvfile) {
kvfile = kv_open("/tmp/kvfile.db");
if (!kvfile) {
@@ -637,11 +638,14 @@ int HAL_Kv_Set(const char *key, const void *val, int len, int sync)
}
}
- return kv_set_blob(kvfile, (char *)key, (char *)val, len);
+ ret = kv_set_blob(kvfile, (char *)key, (char *)val, len);
+ kv_close(kvfile);
+ return ret;
}
int HAL_Kv_Get(const char *key, void *buffer, int *buffer_len)
{
+ int ret;
if (!kvfile) {
kvfile = kv_open("/tmp/kvfile.db");
if (!kvfile) {
@@ -649,11 +653,14 @@ int HAL_Kv_Get(const char *key, void *buffer, int *buffer_len)
}
}
- return kv_get_blob(kvfile, (char *)key, buffer, buffer_len);
+ ret = kv_get_blob(kvfile, (char *)key, buffer, buffer_len);
+ kv_close(kvfile);
+ return ret;
}
int HAL_Kv_Del(const char *key)
{
+ int ret;
if (!kvfile) {
kvfile = kv_open("/tmp/kvfile.db");
if (!kvfile) {
@@ -661,7 +668,9 @@ int HAL_Kv_Del(const char *key)
}
}
- return kv_del(kvfile, (char *)key);
+ ret = kv_del(kvfile, (char *)key);
+ kv_close(kvfile);
+ return ret;
}
static long long os_time_get(void)
