[PATCH] xkb: Fix use of uninitalised memory upon second keyboard init

Dan Nicholson dbn.lists at gmail.com
Thu Feb 26 16:27:55 PST 2009


On Thu, Feb 26, 2009 at 04:22:56PM +1030, Benjamin Close wrote:
> When allocating a second keyboard structure xkbGetRulesDflt
> is called to get the defaults for rmlvo.
> 
> With the second keyboard instance these defaults
> were the values previously allocated in the first call to
> XkbSetRulesDflt; rmlvo is then assigned this value.
> 
> rmlvo is then passed into InitKeyboardDeviceStruct which in turn
> calls xkbSetRulesDflt. xkbSetRulesDflts did:
> 
>     if( xkbRulesDflt )
>          _XkbFree(XkbRulesDflt);
>          XkbRulesDflt= (rmlvo->rules?_XkbDupString(rmlvo->rules):NULL);
> 
> Problem was by freeing XkbRulesDflt, rmlvo->rules was also freed
> hence the dup returned bogus data.
> 
> Fix this problem for both the Dflts and the Used cases.
> 
> Signed-off-by: Benjamin Close <Benjamin.Close at clearchain.com>

Here's what I had in mind. It doesn't fix the case where the caller can
free XKB internal data after calling XkbGetRulesDflts.

--
Dan



More information about the xorg-devel mailing list