Anbei ein Patch welcher das Crash von epghttpd verhindert wenn irgendwas mit dem EventImage nicht stimmt (falsches Format etc)
diff --git a/lib/imgtools.c b/lib/imgtools.c
index 63007e5..f166dec 100644
--- a/lib/imgtools.c
+++ b/lib/imgtools.c
@@ -7,6 +7,25 @@
#include "imgtools.h"
+//***************************************************************************
+// Here's the routine that will replace the standard error_exit method:
+//***************************************************************************
+#include <setjmp.h>
+
+struct my_error_mgr {
+ struct jpeg_error_mgr pub; // public" fields
+ jmp_buf setjmp_buffer; // for return to caller
+};
+typedef struct my_error_mgr * my_error_ptr;
+
+METHODDEF(void)
+my_error_exit (j_common_ptr cinfo)
+{
+ my_error_ptr myerr = (my_error_ptr) cinfo->err;
+ (*cinfo->err->output_message) (cinfo);
+ longjmp(myerr->setjmp_buffer, 1);
+}
+
//***************************************************************************
// Image converting stuff
//***************************************************************************
@@ -14,13 +33,18 @@
int fromJpeg(Imlib_Image& image, unsigned char* buffer, int size)
{
struct jpeg_decompress_struct cinfo;
- struct jpeg_error_mgr jerr;
+ struct my_error_mgr jerr;
int w, h;
DATA8 *ptr, *line[16], *data;
DATA32 *ptr2, *dest;
int x, y;
- cinfo.err = jpeg_std_error(&jerr);
+ cinfo.err = jpeg_std_error(&jerr.pub);
+ jerr.pub.error_exit = my_error_exit;
+ if (setjmp(jerr.setjmp_buffer)) {
+ jpeg_destroy_decompress(&cinfo);
+ return 0;
+ }
jpeg_create_decompress(&cinfo);
jpeg_mem_src(&cinfo, buffer, size);
@@ -76,7 +100,7 @@ int fromJpeg(Imlib_Image& image, unsigned char* buffer, int size)
long toJpeg(Imlib_Image image, MemoryStruct* data, int quality)
{
struct jpeg_compress_struct cinfo;
- struct jpeg_error_mgr jerr;
+ struct my_error_mgr jerr;
DATA32* ptr;
DATA8* buf;
@@ -84,7 +108,12 @@ long toJpeg(Imlib_Image image, MemoryStruct* data, int quality)
data->clear();
- cinfo.err = jpeg_std_error(&jerr);
+ cinfo.err = jpeg_std_error(&jerr.pub);
+ jerr.pub.error_exit = my_error_exit;
+ if (setjmp(jerr.setjmp_buffer)) {
+ jpeg_destroy_compress(&cinfo);
+ return 0;
+ }
jpeg_create_compress(&cinfo);
jpeg_mem_dest(&cinfo, (unsigned char**)(&data->memory), &data->size);