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
Fix teletext memory overflow #17921
Fix teletext memory overflow #17921
Conversation
This patch addresses the three following issues below. The logs are generated with Kodi 18.6-Leia:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow the current code guidelines.
Updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks to start improve of this. Except them memory place it is OK for me.
__GNUC__ is defined by gcc and llvm; This is likely the best option to handle all compilers. |
As a fix mived to Beta1 milestone. However changes are requested @repojohnray, are you able to do this or should this be deferred to v20 |
Updated - This commit is compatible with Nexus. The array is set to 8k and the dynamic version of this line is compatible with gcc and clang. |
Why have a dynamic version for GCC? Surely the static version is more memory-friendly by avoiding the heap? Also we probably don't want behavior to change if someone just flips in a different compiler. |
The original code has this length hardcoded, I have not tried to rewrite the code to avoid this issue. Using variable length array will avoid any memory overflow for future screen resolutions; LLVM is defining GNUC as well. But, you are right, this issue could happen again with compilers incompatible with VLA. |
a105fd5
to
9003b68
Compare
Hi @jenkins4kodi, the commit is updated. |
jenkins build this please |
@@ -2255,7 +2262,11 @@ void CTeletextDecoder::RenderCharIntern(TextRenderInfo_t* RenderInfo, int Char, | |||
|
|||
/* render char */ | |||
sbitbuffer = m_sBit->buffer; | |||
unsigned char localbuffer[1000]; // should be enough to store one character-bitmap... | |||
|
|||
std::vector<unsigned char> localbuffer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know how this part works (teletext) but I think it's very inefficient to create/destroy a vector to render just one character. I suspect that this method will be called multiple times in a row.
It's much better to just increase the buffer size to 2000, 3000, 5000, 10000 or whatever is needed and keep it on the stack. How many pixels does a teletext character have?
The rest of the changes looks fine.
@repojohnray this needs a rebase |
@repojohnray issue did disappear with the last merged change or did you simply gave up on this? |
This is a fix for some memory overflow at the teletext level. These issues were visible with valgrind.