-
-
Notifications
You must be signed in to change notification settings - Fork 307
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
Crash on assigning error_msg to std::string #970
Conversation
Thanks. Can you see the It appears that you are using |
|
Thanks, I've searched the whole code where this might be returned with a |
I am sorry, may be that's my error class Writer:
public heif::Context::Writer
{
public:
Writer(std::vector<unsigned char> & out):
outData_(out)
{};
heif_error write(const void* data, size_t size) override
{
std::copy_n(static_cast<const unsigned char*>(data), size, std::back_inserter(outData_));
return heif_error{ heif_error_Ok };
}
private:
std::vector<unsigned char> & outData_;
}; I think in overrided write function i need fill all fields. I think this may help. Thank you! |
Yes, you should return this: It's a small change, if you want, I can just add this. |
Yes, i can add assert, but as i know assert does not work in release mode. Is it enough that assert will only be in the debug mode? |
Yes, that's intended, as software errors should be detected mainly during development. However, thinking about it again, it might be a better idea to do this
|
Hmm, i little confused. You suggest check err.message. But this logic must be in Error constructor. And i cant return Error from Error constructor) heif_error default_heif_error()
{
return heif_error{ heif_error_Ok, heif_suberror_Unspecified, "Ok" };
} In my case if i saw this function near |
Or may be this one? Error(const heif_error& err)
{
if (!err.msg)
throw Error(heif_error_Usage_error, heif_suberror_Null_pointer_argument, "Writer class returned a null error text");
m_code = err.code;
m_subcode = err.subcode;
m_message = err.message;
} |
I have made the changes. See the two commits above. |
Got it, thank you. Yes, i think this PR can be closed |
Thanks for your help. |
In my project i use heif_cxx.h api. And caught crash inside heif_cxx.h.
It happence while assigning err.message to m_message
Error(const heif_error& err) { m_code = err.code; m_subcode = err.subcode; m_message = err.message; }
Attach debug screen with callStack.
I can't show the fields in the structure, because Qt debugger is stupid, but I hope it's clear.
I read in heif.h file that message in heif_error struct always defined, but apparently not always)