[Poppler-bugs] [Bug 63067] Misuse of setjmp in DCTStream
bugzilla-daemon at freedesktop.org
bugzilla-daemon at freedesktop.org
Thu Apr 4 01:56:46 PDT 2013
https://bugs.freedesktop.org/show_bug.cgi?id=63067
--- Comment #4 from Thomas Freitag <Thomas.Freitag at alfa.de> ---
(In reply to comment #0)
> According to POSIX and the C spec, `setjmp` should only be used as the
> "entire controlling expression" of a selection of iteration statement,
> possibly with `!` or `== 0` or similar.
>
> But in DCTStream.cc is the line:
>
> if (!setjmp(err.setjmp_buffer) && jpeg_read_header(&cinfo, TRUE) !=
> JPEG_SUSPENDED)
This is NOT a iteration statement, iteration statements are "for", "while" and
similar!
>
> If I'm not mistaken, that is undefined behavior. Not that it broke anything
> yet...
>
> Instead it should be:
>
> if (!setjmp(err.setjmp_buffer))
> {
> if (jpeg_read_header(&cinfo, TRUE) != JPEG_SUSPENDED)
Okay, okay, the order of execution of an if condition is undefined in C/C++
(other than if Java, where You can count on that it will be done from left to
right). BUT I never see an c/c++ compiler which does it in another way.
But if we are puristic: Yes, it should be in that way!
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/poppler-bugs/attachments/20130404/93761f61/attachment.html>
More information about the Poppler-bugs
mailing list