diff options
author | Mike Erwin <significant.bit@gmail.com> | 2012-04-25 05:24:29 +0400 |
---|---|---|
committer | Mike Erwin <significant.bit@gmail.com> | 2012-04-25 05:24:29 +0400 |
commit | b12fd22791acd7a709c98ffa3b9ce977b41b35bc (patch) | |
tree | 0d77cfb652632693ed66e076022f8489ad3fd450 | |
parent | 0943f4bc775f960251aa4acf62d84887007ad58a (diff) |
ndof: avoid potential buffer overflow in libspnav
-rw-r--r-- | intern/ghost/intern/GHOST_NDOFManagerX11.cpp | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/intern/ghost/intern/GHOST_NDOFManagerX11.cpp b/intern/ghost/intern/GHOST_NDOFManagerX11.cpp index 1e025cd738a..1e78cafd4f6 100644 --- a/intern/ghost/intern/GHOST_NDOFManagerX11.cpp +++ b/intern/ghost/intern/GHOST_NDOFManagerX11.cpp @@ -75,28 +75,32 @@ bool GHOST_NDOFManagerX11::available() bool GHOST_NDOFManagerX11::processEvents() { - GHOST_TUns64 now = m_system.getMilliSeconds(); - bool anyProcessed = false; - spnav_event e; - while (spnav_poll_event(&e)) { - switch (e.type) { - case SPNAV_EVENT_MOTION: - { - /* convert to blender view coords */ - short t[3] = {e.motion.x, e.motion.y, -e.motion.z}; - short r[3] = {-e.motion.rx, -e.motion.ry, e.motion.rz}; - updateTranslation(t, now); - updateRotation(r, now); - break; + if (m_available) { + GHOST_TUns64 now = m_system.getMilliSeconds(); + + spnav_event e; + while (spnav_poll_event(&e)) { + switch (e.type) { + case SPNAV_EVENT_MOTION: + { + /* convert to blender view coords */ + short t[3] = {e.motion.x, e.motion.y, -e.motion.z}; + short r[3] = {-e.motion.rx, -e.motion.ry, e.motion.rz}; + + updateTranslation(t, now); + updateRotation(r, now); + break; + } + case SPNAV_EVENT_BUTTON: + updateButton(e.button.bnum, e.button.press, now); + break; } - case SPNAV_EVENT_BUTTON: - updateButton(e.button.bnum, e.button.press, now); - break; + anyProcessed = true; } - anyProcessed = true; } + return anyProcessed; } |