Skip to content

Commit

Permalink
cachedb_mongodb: Check return value
Browse files Browse the repository at this point in the history
CID #216626, #216624
  • Loading branch information
oanatitoc committed Sep 23, 2024
1 parent 9e19dd1 commit 98d4a56
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion modules/cachedb_mongodb/cachedb_mongodb_dbase.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,10 @@ int mongo_raw_find(cachedb_con *con, bson_t *raw_query, bson_iter_t *ns,
v = bson_iter_value(&iter);
bson_init_static(&proj, v->value.v_doc.data, v->value.v_doc.data_len);
#if MONGOC_CHECK_VERSION(1, 5, 0)
bson_append_document(opts, "projection", 10, &proj);
if (!bson_append_document(opts, "projection", 10, &proj)) {
LM_ERR("failed to append doc\n");
return -1;
}
#else
fields = &proj;
#endif
Expand Down
6 changes: 5 additions & 1 deletion modules/cachedb_mongodb/cachedb_mongodb_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ int json_to_bson_append_element(bson_t *doc, const char *k, struct json_object *
bson_t child;

if (!v) {
bson_append_null(doc, k, -1);
if (!bson_append_null(doc, key, -1)) {
LM_ERR("failed to append NULL doc\n");
return -1;
}

return 0;
}

Expand Down

0 comments on commit 98d4a56

Please sign in to comment.