summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUli Schlachter <psychon@znc.in>2017-12-23 13:04:59 +0100
committerUli Schlachter <psychon@znc.in>2017-12-23 13:07:56 +0100
commit2acc4382c54bd8239361ceed14423412a343d311 (patch)
tree9c2fed096d239c0c44883db8bef464a45b8078fc
parent3d98047095cdb5e3465b80ce7ea2162b514c0ecf (diff)
Revert "fix warning: variable X might be clobbered by 'longjmp'"
This reverts commit b092b63119cbfe3cb4bc786eee81630998996acf which introduced a wrapper function around setjmp(). To quote from man setjmp: If the function which called setjmp() returns before longjmp() is called, the behavior is undefined. Some kind of subtle or unsubtle chaos is sure to result. Since after the above commit setjmp() is called from the wrapper function, the result might or might not work, depending on compiler settings. If the setjmp() wrapper is not inlined, then the state of the stack after longjmp() will likely be garbage. [Cherry-Pick:] This is a cherry-pick from a master branch to the 1.14 branch. The reverted commit was cherry-picked to this branch in commit d53db01d01a48c48a1633a8d531f979a99d316bd, so this is what this commit actually reverts.
-rw-r--r--src/cairo-bentley-ottmann-rectangular.c8
-rw-r--r--src/cairo-png.c17
2 files changed, 7 insertions, 18 deletions
diff --git a/src/cairo-bentley-ottmann-rectangular.c b/src/cairo-bentley-ottmann-rectangular.c
index cb2e30c8a..5541bdc3a 100644
--- a/src/cairo-bentley-ottmann-rectangular.c
+++ b/src/cairo-bentley-ottmann-rectangular.c
@@ -593,12 +593,6 @@ sweep_line_insert (sweep_line_t *sweep, rectangle_t *rectangle)
pqueue_push (sweep, rectangle);
}
-static int
-sweep_line_setjmp (sweep_line_t *sweep_line)
-{
- return setjmp (sweep_line->unwind);
-}
-
static cairo_status_t
_cairo_bentley_ottmann_tessellate_rectangular (rectangle_t **rectangles,
int num_rectangles,
@@ -615,7 +609,7 @@ _cairo_bentley_ottmann_tessellate_rectangular (rectangle_t **rectangles,
rectangles, num_rectangles,
fill_rule,
do_traps, container);
- if ((status = sweep_line_setjmp (&sweep_line)))
+ if ((status = setjmp (sweep_line.unwind)))
return status;
rectangle = rectangle_pop_start (&sweep_line);
diff --git a/src/cairo-png.c b/src/cairo-png.c
index e64b14a5f..068617d58 100644
--- a/src/cairo-png.c
+++ b/src/cairo-png.c
@@ -158,14 +158,6 @@ png_simple_warning_callback (png_structp png,
*/
}
-static int
-png_setjmp (png_struct *png)
-{
-#ifdef PNG_SETJMP_SUPPORTED
- return setjmp (png_jmpbuf (png));
-#endif
- return 0;
-}
/* Starting with libpng-1.2.30, we must explicitly specify an output_flush_fn.
* Otherwise, we will segfault if we are writing to a stream. */
@@ -237,8 +229,10 @@ write_png (cairo_surface_t *surface,
goto BAIL4;
}
- if (png_setjmp (png))
+#ifdef PNG_SETJMP_SUPPORTED
+ if (setjmp (png_jmpbuf (png)))
goto BAIL4;
+#endif
png_set_write_fn (png, closure, write_func, png_simple_output_flush_fn);
@@ -577,11 +571,12 @@ read_png (struct png_read_closure_t *png_closure)
png_set_read_fn (png, png_closure, stream_read_func);
status = CAIRO_STATUS_SUCCESS;
-
- if (png_setjmp (png)) {
+#ifdef PNG_SETJMP_SUPPORTED
+ if (setjmp (png_jmpbuf (png))) {
surface = _cairo_surface_create_in_error (status);
goto BAIL;
}
+#endif
png_read_info (png, info);