]>
Commit | Line | Data |
---|---|---|
33de0b0d JB |
1 | --- ekg-1.6/src/events.c.orig 2005-10-09 12:50:15.000000000 +0200 |
2 | +++ ekg-1.6/src/events.c 2006-02-20 00:04:49.218225000 +0100 | |
3 | @@ -33,6 +33,7 @@ | |
4 | #include <stdio.h> | |
5 | #include <stdlib.h> | |
6 | #include <string.h> | |
7 | +#include <setjmp.h> | |
8 | #include <unistd.h> | |
9 | ||
10 | #include "commands.h" | |
11 | @@ -1515,6 +1516,21 @@ | |
12 | return NULL; | |
13 | } | |
14 | ||
15 | +#ifdef HAVE_LIBJPEG | |
16 | + | |
17 | +struct ekg_jpeg_error_mgr { | |
18 | + struct jpeg_error_mgr pub; | |
19 | + jmp_buf setjmp_buffer; | |
20 | +}; | |
21 | + | |
22 | +void ekg_jpeg_error_exit(j_common_ptr j) | |
23 | +{ | |
24 | + struct ekg_jpeg_error_mgr *e = (struct ekg_jpeg_error_mgr *) j->err; | |
25 | + /* Return control to the setjmp point */ | |
26 | + longjmp(e->setjmp_buffer, 1); | |
27 | +} | |
28 | +#endif | |
29 | + | |
30 | /* | |
31 | * handle_token() | |
32 | * | |
33 | @@ -1569,7 +1585,7 @@ | |
34 | #ifdef HAVE_LIBJPEG | |
35 | if (config_display_token) { | |
36 | struct jpeg_decompress_struct j; | |
37 | - struct jpeg_error_mgr e; | |
38 | + struct ekg_jpeg_error_mgr e; | |
39 | JSAMPROW buf[1]; | |
40 | int size; | |
41 | char *token, *tmp; | |
42 | @@ -1581,7 +1597,18 @@ | |
43 | goto fail; | |
44 | } | |
45 | ||
46 | - j.err = jpeg_std_error(&e); | |
47 | + j.err = jpeg_std_error(&e.pub); | |
48 | + e.pub.error_exit = ekg_jpeg_error_exit; | |
49 | + /* Establish the setjmp return context for ekg_jpeg_error_exit to use. */ | |
50 | + if (setjmp(e.setjmp_buffer)) { | |
51 | + char buf[JMSG_LENGTH_MAX]; | |
52 | + /* If we ended up over here, then it means some call below called longjmp. */ | |
53 | + (e.pub.format_message)((j_common_ptr)&j, buf); | |
54 | + print("token_failed", buf); | |
55 | + jpeg_destroy_decompress(&j); | |
56 | + fclose(f); | |
57 | + goto fail; | |
58 | + } | |
59 | jpeg_create_decompress(&j); | |
60 | jpeg_stdio_src(&j, f); | |
61 | jpeg_read_header(&j, TRUE); | |
62 | @@ -1623,7 +1650,7 @@ | |
63 | ||
64 | unlink(file); | |
65 | } else | |
66 | -#else /* HAVE_LIBJPEG */ | |
67 | +#endif /* HAVE_LIBJPEG */ | |
68 | { | |
69 | char *file2 = saprintf("%s.jpg", file); | |
70 | ||
71 | @@ -1634,7 +1661,6 @@ | |
72 | ||
73 | xfree(file2); | |
74 | } | |
75 | -#endif /* HAVE_LIBJPEG */ | |
76 | ||
77 | #else /* HAVE_MKSTEMP */ | |
78 | print("token_unsupported"); |