Re: [hatari-devel] SDL GUI file and directory selection

[ Thread Index | Date Index | More Archives ]

Am Tue, 18 Oct 2022 21:55:36 +0200
schrieb Andreas Grabher <andreas_g86@xxxxxxxxxx>:
> I got one last question:
> I noticed that File_MakeValidPathName() outputs just '\0‘ if the input is
> "/somefile" (some file selected in root directory). I think it should
> return "/" instead.

Sounds reasonable, yes!

> It seems that the if-statement "if (pPathName[0])“ is causing that issue.
> I tried removing it and didn’t see any regression yet. Does anyone have an
> idea why this if-statement exists? The explanation of the function tells
> that empty strings should be left as-is. What does this mean? At least it
> does not seem to work properly.

As far as I understand, the intention here is to avoid writing past the end
of a buffer of empty input strings, e.g. the calling code is doing
something like this:

   char str[1] = "";

But the check seems to be at the wrong location. It should be done at the
beginning of the function instead:

Thanks for the hint!


Mail converted by MHonArc 2.6.19+