Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: 'cd' built-in crashed zsh on a broken file system



On Sat, Jan 24, 2015 at 8:09 PM, Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> On Tue, Jan 20, 2015 at 9:34 PM, Peter Stephenson
> <p.w.stephenson@xxxxxxxxxxxx> wrote:
>>
>> How about this?
>>
>> diff --git a/Src/utils.c b/Src/utils.c
>> index 4561b5e..cf18f12 100644
>> --- a/Src/utils.c
>> +++ b/Src/utils.c
>> @@ -1108,10 +1108,13 @@ getnameddir(char *name)
>>         if ((pw = getpwnam(name))) {
>>             char *dir = isset(CHASELINKS) ? xsymlink(pw->pw_dir)
>>                 : ztrdup(pw->pw_dir);
>> -           adduserdir(name, dir, ND_USERNAME, 1);
>> -           str = dupstring(dir);
>> -           zsfree(dir);
>> -           return str;
>> +           if (dir) {
>> +               adduserdir(name, dir, ND_USERNAME, 1);
>> +               str = dupstring(dir);
>> +               zsfree(dir);
>> +               return str;
>> +           } else
>> +               return ztrdup(pw->pw_dir);
>
> This ztrdup triggered a couple of errors in valgrind. Since everything
> else returned from getnameddir seems to be heap allocated, should this
> be dupstring instead?

At this point, just assume I mean coverity if I ever mention valgrind.
I don't know why this happens...

-- 
Mikael Magnusson



Messages sorted by: Reverse Date, Date, Thread, Author