Bug 83797

Summary: [EFL] [DRT] Feeding key events with invalid keyName
Product: WebKit Reporter: Sudarsana Nagineni (babu) <naginenis>
Component: WebKit EFLAssignee: Sudarsana Nagineni (babu) <naginenis>
Status: RESOLVED FIXED    
Severity: Normal CC: gyuyoung.kim, lucas.de.marchi, pnormand, rakuco, tonikitoo, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
pnormand: review-, pnormand: commit-queue-
Patch none

Description Sudarsana Nagineni (babu) 2012-04-12 11:13:31 PDT
keyName passed to KeyEventInfo is not valid after this function returns, so use CString to keep the keyName valid within the scope of KeyEventInfo.

static KeyEventInfo* createKeyEventInfo(JSContextRef context, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
....
const CString cCharacter = character.get()->ustring().utf8();
....
if (!keyName)
     keyName = cCharacter.data();

return new KeyEventInfo(keyName, modifiers);
}
Comment 1 Sudarsana Nagineni (babu) 2012-04-12 11:40:06 PDT
Created attachment 136942 [details]
Patch

Using CString to keep the keyName valid within scope of KeyEventInfo
Comment 2 Raphael Kubo da Costa (:rakuco) 2012-04-13 10:27:26 PDT
Comment on attachment 136942 [details]
Patch

Makes sense, thanks.
Comment 3 Philippe Normand 2012-04-16 04:42:17 PDT
Comment on attachment 136942 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=136942&action=review

> Tools/DumpRenderTree/efl/EventSender.cpp:437
>      const CString cCharacter = character.get()->ustring().utf8();
>      const char* keyName = (location == DomKeyLocationNumpad) ? keyPadNameFromJSValue(character.get()) : keyNameFromJSValue(character.get());
> -    if (!keyName)
> -        keyName = cCharacter.data();
>  
> -    return new KeyEventInfo(keyName, modifiers);
> +    return new KeyEventInfo(keyName ? CString(keyName) : cCharacter, modifiers);

Seems like keyPadNameFromJSValue() should return a CString now. That would simplify this code block, I think.
Comment 4 Sudarsana Nagineni (babu) 2012-04-16 06:36:54 PDT
(In reply to comment #3)
> (From update of attachment 136942 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=136942&action=review
> 
> > Tools/DumpRenderTree/efl/EventSender.cpp:437
> >      const CString cCharacter = character.get()->ustring().utf8();
> >      const char* keyName = (location == DomKeyLocationNumpad) ? keyPadNameFromJSValue(character.get()) : keyNameFromJSValue(character.get());
> > -    if (!keyName)
> > -        keyName = cCharacter.data();
> >  
> > -    return new KeyEventInfo(keyName, modifiers);
> > +    return new KeyEventInfo(keyName ? CString(keyName) : cCharacter, modifiers);
> 
> Seems like keyPadNameFromJSValue() should return a CString now. That would simplify this code block, I think.

Thanks for your review Philippe.
Yes, it simplifies the code. I will update the patch.
Comment 5 Sudarsana Nagineni (babu) 2012-04-16 06:46:10 PDT
Created attachment 137335 [details]
Patch

fixed review comment #3.
Comment 6 WebKit Review Bot 2012-04-16 07:17:48 PDT
Comment on attachment 137335 [details]
Patch

Clearing flags on attachment: 137335

Committed r114250: <http://trac.webkit.org/changeset/114250>
Comment 7 WebKit Review Bot 2012-04-16 07:17:53 PDT
All reviewed patches have been landed.  Closing bug.