Revision: 77686
http://sourceforge.net/p/brlcad/code/77686
Author: brlcad
Date: 2020-11-04 19:27:38 +0000 (Wed, 04 Nov 2020)
Log Message:
-----------
change the search set iteration to also not try and ptbl_get an empty search
set. fixes two distinct segfaults when there aren't paths.
Modified Paths:
--------------
brlcad/trunk/src/libged/search/search.c
Modified: brlcad/trunk/src/libged/search/search.c
===================================================================
--- brlcad/trunk/src/libged/search/search.c 2020-11-04 19:10:55 UTC (rev
77685)
+++ brlcad/trunk/src/libged/search/search.c 2020-11-04 19:27:38 UTC (rev
77686)
@@ -455,17 +455,22 @@
* return one unique list of objects. If one or more paths are non-local,
* each path is treated as its own search */
if (all_local) {
+ size_t len;
struct bu_ptbl *uniq_db_objs;
- size_t len = BU_PTBL_LEN(search_set);
BU_ALLOC(uniq_db_objs, struct bu_ptbl);
BU_PTBL_INIT(uniq_db_objs);
- for (i = len - 1; i >= 0; i--) {
+ for (i = 0; i < BU_PTBL_LEN(search_set); i++) {
size_t path_cnt = 0;
- struct ged_search *search = (struct ged_search
*)BU_PTBL_GET(search_set, i);
- struct directory *curr_path = search->paths[path_cnt];
+ struct ged_search *search;
+ struct directory *curr_path;
+ search = (struct ged_search *)BU_PTBL_GET(search_set, i);
+ if (!search || !search->paths)
+ continue;
+ curr_path = search->paths[path_cnt];
+
while (path_cnt < search->path_cnt) {
flags |= DB_SEARCH_RETURN_UNIQ_DP;
(void)db_search(uniq_db_objs, flags,
bu_vls_addr(&search_string), 1, &curr_path, gedp->ged_wdbp->dbip, ctx);
@@ -477,9 +482,11 @@
/* For this return, we want a list of all unique leaf objects */
bu_sort((void *)BU_PTBL_BASEADDR(uniq_db_objs),
BU_PTBL_LEN(uniq_db_objs), sizeof(struct directory *), dp_name_compare, NULL);
- for (i = BU_PTBL_LEN(uniq_db_objs) - 1; i >= 0; i--) {
- struct directory *uniq_dp = (struct directory
*)BU_PTBL_GET(uniq_db_objs, i);
+ len = BU_PTBL_LEN(uniq_db_objs);
+ while (len > 0) {
+ struct directory *uniq_dp = (struct directory
*)BU_PTBL_GET(uniq_db_objs, len-1);
bu_vls_printf(gedp->ged_result_str, "%s\n", uniq_dp->d_namep);
+ len--;
}
bu_ptbl_free(uniq_db_objs);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits