[PATCH v4 6/7] Replace alloc+strcpy+strcat with asprintf() & XNFasprintf() calls
Julien Cristau
jcristau at debian.org
Sun Dec 5 05:32:45 PST 2010
On Sun, Dec 5, 2010 at 11:10:23 +0100, walter harms wrote:
> > diff --git a/hw/xfree86/common/xf86ShowOpts.c b/hw/xfree86/common/xf86ShowOpts.c
> > index ce86090..c0fa80a 100644
> > --- a/hw/xfree86/common/xf86ShowOpts.c
> > +++ b/hw/xfree86/common/xf86ShowOpts.c
> > @@ -97,11 +97,8 @@ void DoShowOptions (void) {
> > );
> > continue;
> > }
> > - pSymbol = malloc(
> > - strlen(xf86DriverList[i]->driverName) + strlen("ModuleData") + 1
> > - );
> > - strcpy (pSymbol, xf86DriverList[i]->driverName);
> > - strcat (pSymbol, "ModuleData");
> > + XNFasprintf(&pSymbol, "%sModuleData",
> > + xf86DriverList[i]->driverName);
>
>
> every code before checks the return value of asprintf but not here ?
>
The "NF" variant doesn't fail, it calls FatalError if it can't allocate
memory.
Cheers,
Julien
More information about the xorg-devel
mailing list