-
Notifications
You must be signed in to change notification settings - Fork 103
Framebuffer overflow protection #124
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
Conversation
12d459e
to
8ac6cde
Compare
Changing But, as I said before, a raw dynamic buffer may be needed in the future, e.g. to replace m_is_event_animated. So it might be better to refactor this in class first. Then wrap it with another class FrameBuffer {
private:
ReusableBuffer m_buffer;
public:
float* ensure_size(size_t width, size_t height) {
if (width == 0 || width > FRAMEBUFFER_MAX_WIDTH || height == 0 || height > FRAMEBUFFER_MAX_HEIGHT) {
return NULL;
}
const size_t new_size = width * height * 4 * sizeof(float);
return (float*)m_buffer.ensure_size(new_size, false);
}
size_t size() const {
return m_buffer.size();
}
}; |
8ac6cde
to
5383774
Compare
Because of this it will be difficult to use the mentioned Would it be sufficient to check the size in the |
@@ -159,6 +164,13 @@ class SubtitleOctopus { | |||
|
|||
/* CANVAS */ | |||
void resizeCanvas(int frame_w, int frame_h) { | |||
if (frame_w > FRAMEBUFFER_MAX_WIDTH || frame_h > FRAMEBUFFER_MAX_HEIGHT) { |
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.
Hmm, what about <= 0
? Exit with some code or set some default values?
Also, portrait orientation 🤔 Lazy option - FRAMEBUFFER_MAX_SIZE = 8192
for both.
5383774
to
314e519
Compare
314e519
to
fecd5e5
Compare
Using custom magic constant to guard against type overflows is incorrect. Superseded by #133. |
Quick fix for #120 (comment)
Personally, I don't like re-calculation of size at this linememset(buf, 0, sizeof(float) * width * height * 4);
Stored in a variable before calling
buffer_resize
.I am thinking about:Storing the
size
is not suitable forReusableBuffer
. But it is fine forFrameBuffer
.