From: Jeff King Date: Fri, 09 Sep 2022 02:21:58 GMT Subject: Re: [PATCH] builtin/mv.c: fix possible segfault in add_slash() Message-ID: In-Reply-To: <20220908230223.239970-1-shaoxuan.yuan02@gmail.com> On Thu, Sep 08, 2022 at 04:02:23PM -0700, Shaoxuan Yuan wrote: > The purpose of add_slash() is adding a slash to the end of a string to > construct a directory path. And, because adding a slash to an empty > string is of no use here, and checking the string value without checking > it is non-empty leads to segfault, we should make sure the length of the > string is positive to solve both problems. Thanks for picking this up. I had forgotten about it. The patch looks obviously fine to me from the perspective of stopping the segfault. I'll take your "of no use here" as a given, not being familiar with the subtleties of mv's path handling. :) Assuming that's correct, then everything looks good to me. -Peff