Skip to content
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

invalid memory access #32

Open
alexlocher opened this issue Oct 21, 2017 · 1 comment
Open

invalid memory access #32

alexlocher opened this issue Oct 21, 2017 · 1 comment

Comments

@alexlocher
Copy link

Hi Mayank
Thanks for the nice and lightweigtht exif library!

I just run into the situation where a 'std::length_error' on string resize was thrown. It boils down to the following line in exif.cpp:350

      if (result.val_string()[result.val_string().length() - 1] == '\0') {
        result.val_string().resize(result.val_string().length() - 1);
      }

The length of val_string() is not guaranteed to be > 0 and in my case it happend to be empty (resulting in an invalid memory access). The fix is easy:

      if (!result.val_string().empty() && result.val_string()[result.val_string().length() - 1] == '\0') {
        result.val_string().resize(result.val_string().length() - 1);
      }

Cheers & have a nice day
Alex

@ryuchihoon
Copy link

The same issue here.
Your fix is correct. Thank you !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants