- Notifications
You must be signed in to change notification settings - Fork 300
Fix seg fault when using iconv_open() #2403
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
Conversation
Codecov Report
@@ Coverage Diff @@ ## main #2403 +/- ## ========================================== + Coverage 64.28% 64.46% +0.18% ========================================== Files 119 119 Lines 21135 21139 +4 Branches 10430 10435 +5 ========================================== + Hits 13586 13627 +41 + Misses 5400 5353 -47 - Partials 2149 2159 +10
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
- Fix failure condition for `iconv_open()` - Add new exception when failing to change the text encoding of an Exif comment
de30ed7 to 7d69936 Compare
piponazo left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good to me. Thanks for the additional error checking!
| iconv_t cd; | ||
| cd = iconv_open(to, from); | ||
| if (!cd) { | ||
| if (cd == (iconv_t)(-1)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[suggestion] could you define and assign the cd in the same line? Furthermore, is it really needed the cast to iconv_t if we already know that the variable cd is of that type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
musl libc (and most others) have it as
typedef void *iconv_t;
uclibc-ng has it as
typedef long iconv_t;
cast is needed if it's a pointer I think.
This does trigger a clang-tidy check that it's a C cast.
I wonder if there's a C++ way to do this...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
musl libc (and most others) have it as
typedef void *iconv_t;uclibc-ng has it as
typedef long iconv_t;
Thanks for letting me know, I wasn't aware of the different definitions. As for a C++ solution, would using std::is_pointer_v help?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No i mean you can't use static_cast or reinterpret_cast as it would fail with void* and long respectively.
if std::is_pointer_v<cd> ? reinterpret_cast<iconv_t>(-1) : static_cast<iconv_t>(-1)) is quite verbose.
if (iconv_t(-1)) is an alternative but newer clang-tidy warns on that as well.
While looking at one of your current PRs, I was reminded of this discussion. As we are about to release a new version based on the |
| Not really. The clang-tidy check is just stylistic. |
Thanks for checking, I was wondering about this but was pushed for time. |
icon_open(). From the iconv_open(3) manpage:Bug is on the
mainbranch and does not affect exiv2 0.27.5.