htsAddLink() builds its codebase and then walks back to the last /:
a = codebase + strlen(codebase) - 1;
while ((*a) && (*a != '/') && (a > codebase))
a--;
When codebase is empty, a is codebase - 1 and the loop dereferences it before a > codebase stops it. That is the same idiom #729 fixes in lienrelatif(), one byte read before a stack buffer.
codebase is strcpybuffed from heap(ptr)->fil or from heap(heap(ptr)->precedent)->fil, so whether an empty value reaches it depends on which links can carry an empty fil. I have not built a reproducer, and unlike the lienrelatif() case there is no query-stripping pre-pass handing it an empty string, so this may well be unreachable in practice. Filing it because the shape is identical and the guard is one line either way.
Found while reviewing the same idiom for #729. Untouched by that PR and by #718.
htsAddLink()builds its codebase and then walks back to the last/:When
codebaseis empty,aiscodebase - 1and the loop dereferences it beforea > codebasestops it. That is the same idiom #729 fixes inlienrelatif(), one byte read before a stack buffer.codebaseisstrcpybuffed fromheap(ptr)->filor fromheap(heap(ptr)->precedent)->fil, so whether an empty value reaches it depends on which links can carry an emptyfil. I have not built a reproducer, and unlike thelienrelatif()case there is no query-stripping pre-pass handing it an empty string, so this may well be unreachable in practice. Filing it because the shape is identical and the guard is one line either way.Found while reviewing the same idiom for #729. Untouched by that PR and by #718.