This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project wmaker-crm.git.
The branch, next has been updated
via c11d884793df6937af2c8476140746fd5044e6eb (commit)
from 87f4f1d4631dd9e09d118df57ca349a26e2a7f40 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://repo.or.cz/w/wmaker-crm.git/commit/c11d884793df6937af2c8476140746fd5044e6eb
commit c11d884793df6937af2c8476140746fd5044e6eb
Author: David Maciejak <[email protected]>
Date: Tue Feb 25 11:57:35 2014 +0700
Added ppm return error code
This patch is adding some more error code return value
for ppm module.
diff --git a/wrlib/load_ppm.c b/wrlib/load_ppm.c
index b45d0f0e..e8e1ab3f 100644
--- a/wrlib/load_ppm.c
+++ b/wrlib/load_ppm.c
@@ -112,12 +112,16 @@ static RImage *load_graymap(FILE * file, int w, int h,
int max, int raw)
unsigned char *ptr;
int x, y;
- image = RCreateImage(w, h, 0);
- if (!image)
+ if (raw != '2' && raw != '5') {
+ RErrorCode = RERR_BADFORMAT;
return NULL;
+ }
- if (raw != '2' && raw != '5')
- return image;
+ image = RCreateImage(w, h, 0);
+ if (!image) {
+ RErrorCode = RERR_NOMEMORY;
+ return NULL;
+ }
if (max < 256) {
ptr = image->data;
@@ -129,6 +133,7 @@ static RImage *load_graymap(FILE * file, int w, int h, int
max, int raw)
if (val > max || val < 0) {
RErrorCode = RERR_BADIMAGEFILE;
+ RReleaseImage(image);
return NULL;
}
@@ -142,12 +147,16 @@ static RImage *load_graymap(FILE * file, int w, int h,
int max, int raw)
if (raw == '5') {
char *buf;
buf = malloc(w + 1);
- if (!buf)
+ if (!buf) {
+ RErrorCode = RERR_NOMEMORY;
+ RReleaseImage(image);
return NULL;
+ }
for (y = 0; y < h; y++) {
if (!fread(buf, w, 1, file)) {
free(buf);
RErrorCode = RERR_BADIMAGEFILE;
+ RReleaseImage(image);
return NULL;
}
@@ -171,12 +180,16 @@ static RImage *load_pixmap(FILE * file, int w, int h, int
max, int raw)
unsigned char *ptr;
int i = 0;
- image = RCreateImage(w, h, 0);
- if (!image)
+ if (raw != '3' && raw != '6') {
+ RErrorCode = RERR_BADFORMAT;
return NULL;
+ }
- if (raw != '3' && raw != '6')
- return image;
+ image = RCreateImage(w, h, 0);
+ if (!image) {
+ RErrorCode = RERR_NOMEMORY;
+ return NULL;
+ }
ptr = image->data;
if (max < 256) {
@@ -189,6 +202,7 @@ static RImage *load_pixmap(FILE * file, int w, int h, int
max, int raw)
if (val > max || val < 0) {
RErrorCode =
RERR_BADIMAGEFILE;
+ RReleaseImage(image);
return NULL;
}
@@ -202,6 +216,7 @@ static RImage *load_pixmap(FILE * file, int w, int h, int
max, int raw)
while (i < w * h) {
if (fread(buf, 1, 3, file) != 3) {
RErrorCode = RERR_BADIMAGEFILE;
+ RReleaseImage(image);
return NULL;
}
@@ -222,12 +237,16 @@ static RImage *load_bitmap(FILE * file, int w, int h, int
max, int raw)
int val;
unsigned char *ptr;
- image = RCreateImage(w, h, 0);
- if (!image)
+ if (raw != '1' && raw != '4') {
+ RErrorCode = RERR_BADFORMAT;
return NULL;
+ }
- if (raw != '1' && raw != '4')
- return image;
+ image = RCreateImage(w, h, 0);
+ if (!image) {
+ RErrorCode = RERR_NOMEMORY;
+ return NULL;
+ }
ptr = image->data;
if (raw == '1') {
@@ -237,6 +256,7 @@ static RImage *load_bitmap(FILE * file, int w, int h, int
max, int raw)
if (val > max || val < 0) {
RErrorCode = RERR_BADIMAGEFILE;
+ RReleaseImage(image);
return NULL;
}
-----------------------------------------------------------------------
Summary of changes:
wrlib/load_ppm.c | 46 +++++++++++++++++++++++++++++++++-------------
1 files changed, 33 insertions(+), 13 deletions(-)
repo.or.cz automatic notification. Contact project admin [email protected]
if you want to unsubscribe, or site admin [email protected] if you receive
no reply.
--
wmaker-crm.git ("The Window Maker window manager")
--
To unsubscribe, send mail to [email protected].