Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[input] fix stack overflow in HasLongpressMapping #7846

Merged
merged 1 commit into from Aug 27, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 10 additions & 8 deletions xbmc/input/ButtonTranslator.cpp
Expand Up @@ -1155,9 +1155,8 @@ int CButtonTranslator::GetFallbackWindow(int windowID)
if (fallbackWindows[index].origin == windowID)
return fallbackWindows[index].target;
}
// for addon windows use WINDOW_ADDON_START
// because id is dynamic
if (windowID >= WINDOW_ADDON_START && windowID <= WINDOW_ADDON_END)
// for addon windows use WINDOW_ADDON_START because id is dynamic
if (windowID > WINDOW_ADDON_START && windowID <= WINDOW_ADDON_END)

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

return WINDOW_ADDON_START;

return -1;
Expand Down Expand Up @@ -1193,9 +1192,13 @@ bool CButtonTranslator::HasLonpressMapping(int window, const CKey &key)
map<int, buttonMap>::const_iterator it = m_translatorMap.find(window);
if (it == m_translatorMap.end())
{
if (window > -1)
return HasLonpressMapping(GetFallbackWindow(window), key);
return false;
// first check if we have a fallback for the window
int fallbackWindow = GetFallbackWindow(window);
if (fallbackWindow > -1 && HasLonpressMapping(fallbackWindow, key))
return true;

// fallback to default section if there is no key mapping found
return HasLonpressMapping(-1, key);
}

uint32_t code = key.GetButtonCode();
Expand All @@ -1215,8 +1218,7 @@ bool CButtonTranslator::HasLonpressMapping(int window, const CKey &key)
return true;
}
#endif
if (window > -1)
return HasLonpressMapping(GetFallbackWindow(window), key);

return false;
}

Expand Down