On Tue, Apr 9, 2024 at 11:30 PM Patrick Steinhardt <ps@xxxxxx> wrote: > > + if (include_spaces) > > + *endp = p + strlen(p); > > + else > > + *endp = strchr(p, ' '); > > + strbuf_add(sb, p, *endp - p); > > strchr(3P) may return a NULL pointer in case there is no space, which > would make us segfault here when dereferencing `*endp`. We should > probably add a testcase that would hit this edge case. Note that you can do: *endp = p + strcspn(p, " "); (though `strcspn` is a fundamentally harder operation since it takes a string argument). Everything depends on whether you want to test for an explicit "there was no space at all" case of course; performance considerations are secondary. Chris