This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to annotated tag 1.42d
in repository iortcw.

commit 9ef70a231d33ec7ee75a559db86814bb74f527d5
Author: MAN-AT-ARMS <m4n4t4...@gmail.com>
Date:   Tue Dec 22 08:19:40 2015 -0500

    All: Fix error handling in RE_SaveJPGToBuffer()
---
 MP/code/rend2/tr_image_jpg.c    | 20 ++++++++++++++++----
 MP/code/renderer/tr_image_jpg.c | 20 ++++++++++++++++----
 SP/code/rend2/tr_image_jpg.c    | 20 ++++++++++++++++----
 SP/code/renderer/tr_image_jpg.c | 20 ++++++++++++++++----
 4 files changed, 64 insertions(+), 16 deletions(-)

diff --git a/MP/code/rend2/tr_image_jpg.c b/MP/code/rend2/tr_image_jpg.c
index 0173d9e..5902b57 100644
--- a/MP/code/rend2/tr_image_jpg.c
+++ b/MP/code/rend2/tr_image_jpg.c
@@ -61,7 +61,7 @@ static void R_JPGErrorExit(j_common_ptr cinfo)
   
   (*cinfo->err->format_message) (cinfo, buffer);
 
-  ri.Printf(PRINT_ALL, "R_LoadJPG() error: %s", buffer);
+  ri.Printf(PRINT_ALL, "Error: %s", buffer);
 
   /* Return control to the setjmp point */
   longjmp(jerr->setjmp_buffer, 1);
@@ -142,7 +142,7 @@ void R_LoadJPG(const char *filename, unsigned char **pic, 
int *width, int *heigh
     ri.FS_FreeFile(fbuffer.v);
 
     /* Append the filename to the error for easier debugging */
-    ri.Printf(PRINT_ALL, ", file %s\n", filename);
+    ri.Printf(PRINT_ALL, ", loading file %s\n", filename);
     return;
   }
 
@@ -388,17 +388,29 @@ size_t RE_SaveJPGToBuffer(byte *buffer, size_t bufSize, 
int quality,
     int image_width, int image_height, byte *image_buffer, int padding)
 {
   struct jpeg_compress_struct cinfo;
-  struct jpeg_error_mgr jerr;
+  q_jpeg_error_mgr_t jerr;
   JSAMPROW row_pointer[1];     /* pointer to JSAMPLE row[s] */
   my_dest_ptr dest;
   int row_stride;              /* physical row width in image buffer */
   size_t outcount;
 
   /* Step 1: allocate and initialize JPEG compression object */
-  cinfo.err = jpeg_std_error(&jerr);
+  cinfo.err = jpeg_std_error(&jerr.pub);
   cinfo.err->error_exit = R_JPGErrorExit;
   cinfo.err->output_message = R_JPGOutputMessage;
 
+  /* Establish the setjmp return context for R_JPGErrorExit to use. */
+  if (setjmp(jerr.setjmp_buffer))
+  {
+    /* If we get here, the JPEG code has signaled an error.
+     * We need to clean up the JPEG object and return.
+     */
+    jpeg_destroy_compress(&cinfo);
+
+    ri.Printf(PRINT_ALL, "\n");
+    return 0;
+  }
+
   /* Now we can initialize the JPEG compression object. */
   jpeg_create_compress(&cinfo);
 
diff --git a/MP/code/renderer/tr_image_jpg.c b/MP/code/renderer/tr_image_jpg.c
index 0173d9e..5902b57 100644
--- a/MP/code/renderer/tr_image_jpg.c
+++ b/MP/code/renderer/tr_image_jpg.c
@@ -61,7 +61,7 @@ static void R_JPGErrorExit(j_common_ptr cinfo)
   
   (*cinfo->err->format_message) (cinfo, buffer);
 
-  ri.Printf(PRINT_ALL, "R_LoadJPG() error: %s", buffer);
+  ri.Printf(PRINT_ALL, "Error: %s", buffer);
 
   /* Return control to the setjmp point */
   longjmp(jerr->setjmp_buffer, 1);
@@ -142,7 +142,7 @@ void R_LoadJPG(const char *filename, unsigned char **pic, 
int *width, int *heigh
     ri.FS_FreeFile(fbuffer.v);
 
     /* Append the filename to the error for easier debugging */
-    ri.Printf(PRINT_ALL, ", file %s\n", filename);
+    ri.Printf(PRINT_ALL, ", loading file %s\n", filename);
     return;
   }
 
@@ -388,17 +388,29 @@ size_t RE_SaveJPGToBuffer(byte *buffer, size_t bufSize, 
int quality,
     int image_width, int image_height, byte *image_buffer, int padding)
 {
   struct jpeg_compress_struct cinfo;
-  struct jpeg_error_mgr jerr;
+  q_jpeg_error_mgr_t jerr;
   JSAMPROW row_pointer[1];     /* pointer to JSAMPLE row[s] */
   my_dest_ptr dest;
   int row_stride;              /* physical row width in image buffer */
   size_t outcount;
 
   /* Step 1: allocate and initialize JPEG compression object */
-  cinfo.err = jpeg_std_error(&jerr);
+  cinfo.err = jpeg_std_error(&jerr.pub);
   cinfo.err->error_exit = R_JPGErrorExit;
   cinfo.err->output_message = R_JPGOutputMessage;
 
+  /* Establish the setjmp return context for R_JPGErrorExit to use. */
+  if (setjmp(jerr.setjmp_buffer))
+  {
+    /* If we get here, the JPEG code has signaled an error.
+     * We need to clean up the JPEG object and return.
+     */
+    jpeg_destroy_compress(&cinfo);
+
+    ri.Printf(PRINT_ALL, "\n");
+    return 0;
+  }
+
   /* Now we can initialize the JPEG compression object. */
   jpeg_create_compress(&cinfo);
 
diff --git a/SP/code/rend2/tr_image_jpg.c b/SP/code/rend2/tr_image_jpg.c
index 0173d9e..5902b57 100644
--- a/SP/code/rend2/tr_image_jpg.c
+++ b/SP/code/rend2/tr_image_jpg.c
@@ -61,7 +61,7 @@ static void R_JPGErrorExit(j_common_ptr cinfo)
   
   (*cinfo->err->format_message) (cinfo, buffer);
 
-  ri.Printf(PRINT_ALL, "R_LoadJPG() error: %s", buffer);
+  ri.Printf(PRINT_ALL, "Error: %s", buffer);
 
   /* Return control to the setjmp point */
   longjmp(jerr->setjmp_buffer, 1);
@@ -142,7 +142,7 @@ void R_LoadJPG(const char *filename, unsigned char **pic, 
int *width, int *heigh
     ri.FS_FreeFile(fbuffer.v);
 
     /* Append the filename to the error for easier debugging */
-    ri.Printf(PRINT_ALL, ", file %s\n", filename);
+    ri.Printf(PRINT_ALL, ", loading file %s\n", filename);
     return;
   }
 
@@ -388,17 +388,29 @@ size_t RE_SaveJPGToBuffer(byte *buffer, size_t bufSize, 
int quality,
     int image_width, int image_height, byte *image_buffer, int padding)
 {
   struct jpeg_compress_struct cinfo;
-  struct jpeg_error_mgr jerr;
+  q_jpeg_error_mgr_t jerr;
   JSAMPROW row_pointer[1];     /* pointer to JSAMPLE row[s] */
   my_dest_ptr dest;
   int row_stride;              /* physical row width in image buffer */
   size_t outcount;
 
   /* Step 1: allocate and initialize JPEG compression object */
-  cinfo.err = jpeg_std_error(&jerr);
+  cinfo.err = jpeg_std_error(&jerr.pub);
   cinfo.err->error_exit = R_JPGErrorExit;
   cinfo.err->output_message = R_JPGOutputMessage;
 
+  /* Establish the setjmp return context for R_JPGErrorExit to use. */
+  if (setjmp(jerr.setjmp_buffer))
+  {
+    /* If we get here, the JPEG code has signaled an error.
+     * We need to clean up the JPEG object and return.
+     */
+    jpeg_destroy_compress(&cinfo);
+
+    ri.Printf(PRINT_ALL, "\n");
+    return 0;
+  }
+
   /* Now we can initialize the JPEG compression object. */
   jpeg_create_compress(&cinfo);
 
diff --git a/SP/code/renderer/tr_image_jpg.c b/SP/code/renderer/tr_image_jpg.c
index 0173d9e..5902b57 100644
--- a/SP/code/renderer/tr_image_jpg.c
+++ b/SP/code/renderer/tr_image_jpg.c
@@ -61,7 +61,7 @@ static void R_JPGErrorExit(j_common_ptr cinfo)
   
   (*cinfo->err->format_message) (cinfo, buffer);
 
-  ri.Printf(PRINT_ALL, "R_LoadJPG() error: %s", buffer);
+  ri.Printf(PRINT_ALL, "Error: %s", buffer);
 
   /* Return control to the setjmp point */
   longjmp(jerr->setjmp_buffer, 1);
@@ -142,7 +142,7 @@ void R_LoadJPG(const char *filename, unsigned char **pic, 
int *width, int *heigh
     ri.FS_FreeFile(fbuffer.v);
 
     /* Append the filename to the error for easier debugging */
-    ri.Printf(PRINT_ALL, ", file %s\n", filename);
+    ri.Printf(PRINT_ALL, ", loading file %s\n", filename);
     return;
   }
 
@@ -388,17 +388,29 @@ size_t RE_SaveJPGToBuffer(byte *buffer, size_t bufSize, 
int quality,
     int image_width, int image_height, byte *image_buffer, int padding)
 {
   struct jpeg_compress_struct cinfo;
-  struct jpeg_error_mgr jerr;
+  q_jpeg_error_mgr_t jerr;
   JSAMPROW row_pointer[1];     /* pointer to JSAMPLE row[s] */
   my_dest_ptr dest;
   int row_stride;              /* physical row width in image buffer */
   size_t outcount;
 
   /* Step 1: allocate and initialize JPEG compression object */
-  cinfo.err = jpeg_std_error(&jerr);
+  cinfo.err = jpeg_std_error(&jerr.pub);
   cinfo.err->error_exit = R_JPGErrorExit;
   cinfo.err->output_message = R_JPGOutputMessage;
 
+  /* Establish the setjmp return context for R_JPGErrorExit to use. */
+  if (setjmp(jerr.setjmp_buffer))
+  {
+    /* If we get here, the JPEG code has signaled an error.
+     * We need to clean up the JPEG object and return.
+     */
+    jpeg_destroy_compress(&cinfo);
+
+    ri.Printf(PRINT_ALL, "\n");
+    return 0;
+  }
+
   /* Now we can initialize the JPEG compression object. */
   jpeg_create_compress(&cinfo);
 

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-games/iortcw.git

_______________________________________________
Pkg-games-commits mailing list
Pkg-games-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits

Reply via email to