cinecert / asdcplib

AS-DCP and AS-02 File Access Library
Other
70 stars 54 forks source link

Fix read of stack buffer after it went out of scope #55

Closed ArnaudBienner closed 4 years ago

ArnaudBienner commented 4 years ago

Another potential bug found thanks to address sanitizer.

Fix reading data that is actually stored on a stack buffer that went out of scope. More details on the code comment. I think it was working as expected for now because no other variable was allocated on the stack afterwards. If that would be the case one day, this would lead to data corruption (and big headaches to understand what is going on). An alternative could be to not use buffer allocated on the stack but memory allocated on the heap and stored in a shared pointer. This way, it wouldn't matter where the variable is declared.