On 9/15/2021 10:54 AM, Elijah Newren wrote:
quoted
+ /*
+ * Use 'alloc' as an indicator that the string has not been
+ * initialized, in case the parent is the root directory.
+ */
+ if (!path_parent->alloc) {
+ char *slash;
+ strbuf_addstr(path_parent, pathname);
+ slash = find_last_dir_sep(path_parent->buf);
+
+ if (slash)
+ *slash = '\0';
Are you breaking strbuf invariants here? path_parent->len will not be
corrected by this string manipulation. Perhaps replace this if-else
block with
strbuf_setlen(path_parent, slash ? slash - path_parent->buf : 0)
Yes, I am. I noticed and fixed this when I was rewriting this
patch for Ævar's feedback. Thanks for pointing it out.
Thanks,
-Stolee