Skip to content

Commit

Permalink
correct an off-by-one error
Browse files Browse the repository at this point in the history
since our loop starts at i=1, we are not able to request a top matrix.
ie when requesting depth=1, the loop breaks on the first iteration -
always incorrectly returning the initialized identity matrix
  • Loading branch information
f4alt committed Nov 28, 2022
1 parent cc33a7b commit ae8b001
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/librt/db_fullpath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ db_path_to_mat(
mat_t mtmp = MAT_INIT_IDN;
for (size_t i = 1; i < pathp->fp_len; i++) {
mat_t cur_m = MAT_INIT_IDN;
if (depth && i + 1 > (size_t)depth)
if (depth && i > (size_t)depth)
break;
struct directory *cdp = pathp->fp_names[i-1];
struct directory *dp = pathp->fp_names[i];
Expand Down

0 comments on commit ae8b001

Please sign in to comment.