Skip to content
Browse files

X11: fixed invalid usage of sizeof() (squash into x11 changes)

  • Loading branch information...
1 parent b1beb9c commit 446feaffa4c1b7a7208edce89296f450c698e81a @elupus elupus committed with
Showing with 8 additions and 4 deletions.
  1. +7 −4 xbmc/windowing/WinEventsX11.cpp
  2. +1 −0 xbmc/windowing/WinEventsX11.h
View
11 xbmc/windowing/WinEventsX11.cpp
@@ -162,6 +162,7 @@ CWinEventsX11::CWinEventsX11()
m_display = 0;
m_window = 0;
m_keybuf = 0;
+ m_keybuf_len = 0;
}
CWinEventsX11::~CWinEventsX11()
@@ -196,7 +197,8 @@ bool CWinEventsX11::Init(Display *dpy, Window win)
WinEvents = new CWinEventsX11();
WinEvents->m_display = dpy;
WinEvents->m_window = win;
- WinEvents->m_keybuf = (char*)malloc(32*sizeof(char));
+ WinEvents->m_keybuf_len = 32*sizeof(char);
+ WinEvents->m_keybuf = (char*)malloc(WinEvents->m_keybuf_len);
WinEvents->m_keymodState = 0;
WinEvents->m_wmDeleteMessage = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
WinEvents->m_structureChanged = false;
@@ -428,13 +430,14 @@ bool CWinEventsX11::MessagePump()
Status status;
int len;
len = Xutf8LookupString(WinEvents->m_xic, &xevent.xkey,
- WinEvents->m_keybuf, sizeof(WinEvents->m_keybuf),
+ WinEvents->m_keybuf, WinEvents->m_keybuf_len,
&xkeysym, &status);
if (status == XBufferOverflow)
{
- WinEvents->m_keybuf = (char*)realloc(WinEvents->m_keybuf, len*sizeof(char));
+ WinEvents->m_keybuf_len = len;
+ WinEvents->m_keybuf = (char*)realloc(WinEvents->m_keybuf, WinEvents->m_keybuf_len);
len = Xutf8LookupString(WinEvents->m_xic, &xevent.xkey,
- WinEvents->m_keybuf, sizeof(WinEvents->m_keybuf),
+ WinEvents->m_keybuf, WinEvents->m_keybuf_len,
&xkeysym, &status);
}
switch (status)
View
1 xbmc/windowing/WinEventsX11.h
@@ -47,6 +47,7 @@ class CWinEventsX11 : public CWinEventsBase
Window m_window;
Atom m_wmDeleteMessage;
char *m_keybuf;
+ size_t m_keybuf_len;
XIM m_xim;
XIC m_xic;
XBMC_Event m_lastKey;

0 comments on commit 446feaf

Please sign in to comment.
Something went wrong with that request. Please try again.