base: Fix various coverity warnings
This commit is contained in:
@@ -577,7 +577,7 @@ heim_db_commit(heim_db_t db, heim_error_t *error)
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (db->options == NULL)
|
if (db->options)
|
||||||
journal_fname = heim_dict_get_value(db->options, HSTR("journal-filename"));
|
journal_fname = heim_dict_get_value(db->options, HSTR("journal-filename"));
|
||||||
|
|
||||||
if (journal_fname != NULL) {
|
if (journal_fname != NULL) {
|
||||||
@@ -1144,21 +1144,15 @@ enomem:
|
|||||||
static
|
static
|
||||||
heim_data_t from_base64(heim_string_t s, heim_error_t *error)
|
heim_data_t from_base64(heim_string_t s, heim_error_t *error)
|
||||||
{
|
{
|
||||||
|
ssize_t len = -1;
|
||||||
void *buf;
|
void *buf;
|
||||||
size_t len;
|
|
||||||
heim_data_t d;
|
heim_data_t d;
|
||||||
|
|
||||||
buf = malloc(strlen(heim_string_get_utf8(s)));
|
buf = malloc(strlen(heim_string_get_utf8(s)));
|
||||||
if (buf == NULL)
|
if (buf)
|
||||||
goto enomem;
|
|
||||||
|
|
||||||
len = rk_base64_decode(heim_string_get_utf8(s), buf);
|
len = rk_base64_decode(heim_string_get_utf8(s), buf);
|
||||||
d = heim_data_ref_create(buf, len, free);
|
if (len > -1 && (d = heim_data_ref_create(buf, len, free)))
|
||||||
if (d == NULL)
|
|
||||||
goto enomem;
|
|
||||||
return d;
|
return d;
|
||||||
|
|
||||||
enomem:
|
|
||||||
free(buf);
|
free(buf);
|
||||||
if (error)
|
if (error)
|
||||||
*error = heim_error_create_enomem();
|
*error = heim_error_create_enomem();
|
||||||
|
@@ -115,6 +115,8 @@ heim_dict_create(size_t size)
|
|||||||
heim_dict_t dict;
|
heim_dict_t dict;
|
||||||
|
|
||||||
dict = _heim_alloc_object(&dict_object, sizeof(*dict));
|
dict = _heim_alloc_object(&dict_object, sizeof(*dict));
|
||||||
|
if (dict == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
dict->size = findprime(size);
|
dict->size = findprime(size);
|
||||||
if (dict->size == 0) {
|
if (dict->size == 0) {
|
||||||
|
@@ -756,9 +756,10 @@ heim_path_vget2(heim_object_t ptr, heim_object_t *parent, heim_object_t *key,
|
|||||||
next_node = heim_dict_get_value(node, path_element);
|
next_node = heim_dict_get_value(node, path_element);
|
||||||
} else if (node_type == HEIM_TID_DB) {
|
} else if (node_type == HEIM_TID_DB) {
|
||||||
next_node = _heim_db_get_value(node, NULL, path_element, NULL);
|
next_node = _heim_db_get_value(node, NULL, path_element, NULL);
|
||||||
} else if (node_type == HEIM_TID_ARRAY) {
|
} else {
|
||||||
int idx = -1;
|
int idx = -1;
|
||||||
|
|
||||||
|
/* node_type == HEIM_TID_ARRAY */
|
||||||
if (heim_get_tid(path_element) == HEIM_TID_NUMBER)
|
if (heim_get_tid(path_element) == HEIM_TID_NUMBER)
|
||||||
idx = heim_number_get_int(path_element);
|
idx = heim_number_get_int(path_element);
|
||||||
if (idx < 0) {
|
if (idx < 0) {
|
||||||
@@ -770,12 +771,6 @@ heim_path_vget2(heim_object_t ptr, heim_object_t *parent, heim_object_t *key,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
next_node = heim_array_get_value(node, idx);
|
next_node = heim_array_get_value(node, idx);
|
||||||
} else {
|
|
||||||
if (error)
|
|
||||||
*error = heim_error_create(EINVAL,
|
|
||||||
"heim_path_get() node in path "
|
|
||||||
"not a container type");
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
node = next_node;
|
node = next_node;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user