Skip to content

Commit

Permalink
Fixed|libcommon|64-bit: Crash when binding controls in menu
Browse files Browse the repository at this point in the history
Fixed passing of the symbolic event string pointer in the event_t
structure. Reassembly of the 64-bit pointer failed if ev->data1
was negative in its 32-bit integer range.

Todo for later: It isn't a great idea to pass 64-bit pointers like
this, why not just add a pointer member to event_t?
  • Loading branch information
skyjake committed Jul 21, 2013
1 parent 8be2928 commit 4a6ed32
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions doomsday/client/src/ui/dd_input.cpp
Expand Up @@ -1014,8 +1014,8 @@ void DD_ConvertEvent(const ddevent_t* ddEvent, event_t* ev)
ev->type = EV_SYMBOLIC;
#ifdef __64BIT__
ASSERT_64BIT(ddEvent->symbolic.name);
ev->data1 = (int)(((int64_t) ddEvent->symbolic.name) & 0xffffffff); // low dword
ev->data2 = (int)(((int64_t) ddEvent->symbolic.name) >> 32); // high dword
ev->data1 = (int)(((uint64_t) ddEvent->symbolic.name) & 0xffffffff); // low dword
ev->data2 = (int)(((uint64_t) ddEvent->symbolic.name) >> 32); // high dword
#else
ASSERT_NOT_64BIT(ddEvent->symbolic.name);

Expand Down
7 changes: 6 additions & 1 deletion doomsday/plugins/common/src/m_ctrl.c
Expand Up @@ -695,7 +695,12 @@ int MNBindings_PrivilegedResponder(mn_object_t* obj, event_t* ev)
#ifndef __64BIT__
symbol = (const char*) ev->data1;
#else
symbol = (const char*)(((int64_t)ev->data1) | (((int64_t)ev->data2)) << 32);
{
uint64_t address = (uint32_t) ev->data2;
address <<= 32;
address |= (uint32_t) ev->data1;
symbol = (const char*) address;
}
#endif

if(strncmp(symbol, "echo-", 5))
Expand Down

0 comments on commit 4a6ed32

Please sign in to comment.