[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] ext2 bug Was Re: another getcwd fix (includes previous patch)



Alan Hourihane <alanh@fairlite.demon.co.uk> writes:

> @@ -64,12 +74,23 @@
>  			path[0] = '\\';
>  			path[1] = '\0';
>  		}
> -		_dos2unx(path, buf, size);
> +		r = _dos2unx(path, buf, size);
>  	}
> -	else
> +	else {
>  		/* convert DOS filename to unix */
> -		_dos2unx(_path, buf, size);
> +		r = _dos2unx(_path, buf, size);
> +	}
> +
> +	/* dos2unx failed, probably ENAMETOOLONG, so abort now */
> +	if (r == -1) {
> +		free(_path);
> +		if (buf_malloced)
> +			free(buf);
> +		return NULL;

You need to preserve errno around the calls to free.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."