Skip to content

Commit f2b0dae

Browse files
committed
fix(subprocess): return EMPTY before marking when the /proc scan collected nothing
Jenkins DeusData#95 failed in lint-cppcheck (ctunullpointer): when readdir returned no usable entries, procs stayed NULL and was passed to cbm_linux_probe_mark_tree, which calls qsort on it. A zero count made that harmless at runtime, but passing NULL to qsort is undefined. The probe now returns CBM_PROC_TREE_RSS_EMPTY directly when nothing was collected, matching the result the loop would have produced. `scripts/lint.sh --ci` and the subprocess suite (61 pass) pass locally.
1 parent e5a4dc0 commit f2b0dae

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎src/foundation/subprocess.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,10 @@ static cbm_proc_tree_rss_status_t cbm_subprocess_tree_rss_platform(cbm_subproces
948948
cbm_free(CBM_MEM_CLASS_OTHER, procs);
949949
return CBM_PROC_TREE_RSS_ERROR;
950950
}
951+
if (!procs || count == 0) {
952+
cbm_free(CBM_MEM_CLASS_OTHER, procs);
953+
return CBM_PROC_TREE_RSS_EMPTY;
954+
}
951955

952956
cbm_linux_probe_mark_tree(procs, count, process->pgid);
953957
uint64_t total = 0;

0 commit comments

Comments
 (0)