[vlc-devel] [PATCH 4/4] jpeg: add a comment and an assertion to explain error handling

Rafaël Carré funman at videolan.org
Tue Jan 28 11:21:58 CET 2014


---
 modules/codec/jpeg.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/modules/codec/jpeg.c b/modules/codec/jpeg.c
index 0753d63..fa26f15 100644
--- a/modules/codec/jpeg.c
+++ b/modules/codec/jpeg.c
@@ -29,6 +29,7 @@
 #include <vlc_codec.h>
 #include <jpeglib.h>
 #include <setjmp.h>
+#include <assert.h>
 
 /*
  * jpeg decoder descriptor
@@ -113,6 +114,11 @@ static int OpenDecoder(vlc_object_t *p_this)
     p_dec->pf_decode_video = DecodeBlock;
 
     p_sys->p_jpeg.err = jpeg_std_error(&p_sys->err);
+    /* XXX: we rely on p_sys->err being the first member of sys_t struct,
+     * so its address is the same than p_sys and we can retrieve p_sys
+     * address in libjpeg error handlers */
+    assert(p_sys->p_jpeg.err == p_sys);
+
     p_sys->err.error_exit = user_error_exit;
     p_sys->err.output_message = user_error_message;
 
-- 
1.8.5.3




More information about the vlc-devel mailing list