-
Notifications
You must be signed in to change notification settings - Fork 47
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
[1.x] don't keep null clones #164
Conversation
This will crash in the destructor and many other places. It's unlikely to happen by better safe than sorry. (cherry picked from commit ca27cb0) (edited)
Personally I'm not a fan of trying to handle out-of-memory in the library in this way. Most applications including MKVToolNix cannot handle out-of-memory well if at all as doing so requires quite a number of different-to-master techniques. For example, even the process of formatting & outputting useful error messages likely requires allocating even more memory, which will usually fail then, too. Most apps simply abort. I'd rather our libraries aborted in that case as well. It's a situation no sane application will ever be able to recover from. |
I agree when you're short on memory it's better to do as little as possible and return. Any program will likely crash if there's too little memory left. However in this case we're talking about a clone. In the case of an EbmlBinary (or many of them) That could result in huge memory allocation (like large attachments in Matroska) even though there's still plenty of memory for small things. In this case Clone() actually won't return nullptr so this won't be covered here, yet. But IMO the |
Even if the element's Semantically this is a bit like a database transaction: if a database clients starts a transaction it can be sure at the end of it that either all of the actions taken within the transaction have been applied, or none of it. Back to libEBML, the result of |
We can change the API in 2.0 but this is a fix for 1.x. We can't throw in the EbmlMaster copy constructor. But we also can't push null in the vector because it will be used in the destructor (and other places). So this is avoiding some crashes. However it will be in an unstable state. But I think overall it's better than a null dereferencing. |
I kind of disagree that this is in any way better. I'd rather the application die immediately via |
OK, so should I revert #162 ? |
Probably, yeah. Sorry, I only thought about this more after approving 162. |
No worries. |
This will crash in the destructor and many other places.
It's unlikely to happen but better safe than sorry.
(cherry picked from commit ca27cb0) (edited)