Skip to content

invalid memory access #32

@alexlocher

Description

@alexlocher

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions