-
Notifications
You must be signed in to change notification settings - Fork 455
CDRIVER-5756 Coverity fixes #1867
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
ba7520d
c5d318a
e096053
3bf95a7
33ce86f
0cd7445
8faf036
a6c0bb5
9e0abfc
2509ba1
084b2f1
41ac6b5
93a0230
ad9b336
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1149,8 +1149,15 @@ void jsonsl_jpr_match_state_init(jsonsl_t jsn, | |||||||||||||
return; | ||||||||||||||
} | ||||||||||||||
jsn->jprs = (jsonsl_jpr_t *)malloc(sizeof(jsonsl_jpr_t) * njprs); | ||||||||||||||
if (!jsn->jprs) { | ||||||||||||||
return; | ||||||||||||||
} | ||||||||||||||
jsn->jpr_count = njprs; | ||||||||||||||
jsn->jpr_root = (size_t*)calloc(1, sizeof(size_t) * njprs * jsn->levels_max); | ||||||||||||||
rcsanchez97 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
if (!jsn->jpr_root) { | ||||||||||||||
free(jsn->jprs); | ||||||||||||||
return; | ||||||||||||||
} | ||||||||||||||
Comment on lines
1156
to
+1160
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Similarly, use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK. That makes sense. Should I do that as a drive-by in this PR, or a separate PR? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it is OK to include in this PR. Though the other |
||||||||||||||
memcpy(jsn->jprs, jprs, sizeof(jsonsl_jpr_t) * njprs); | ||||||||||||||
/* Set the initial jump table values */ | ||||||||||||||
|
||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -311,10 +311,12 @@ _mongoc_topology_background_monitoring_stop (mongoc_topology_t *topology) | |
} | ||
|
||
/* Signal all RTT monitors to shut down. */ | ||
bson_mutex_lock (&topology->tpld_modification_mtx); | ||
for (size_t i = 0u; i < n_rtt_monitors; i++) { | ||
server_monitor = mongoc_set_get_item (topology->rtt_monitors, i); | ||
mongoc_server_monitor_request_shutdown (server_monitor); | ||
} | ||
bson_mutex_unlock (&topology->tpld_modification_mtx); | ||
Comment on lines
+314
to
+319
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if this mutex is relevant here. Do you have a link to the Coverity warning related to these lines? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I sent you the link in a DM. |
||
|
||
for (size_t i = 0u; i < n_srv_monitors; i++) { | ||
/* Wait for the thread to shutdown. */ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest using
bson_malloc
.bson_malloc
already checks (and aborts) if allocation fails. I expect that will fix the Coverity warning. Usingbson_malloc
ensures allocators set withbson_mem_set_vtable
are used.Also replace
free(jsn->jprs);
withbson_free(jsn->jprs);