
Check malloc() return value properly in jtrans_add().

---

 cur-root/trans.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diff -puN trans.c~malloc_checks trans.c
--- cur/trans.c~malloc_checks	2004-07-22 11:05:36.437804432 -0300
+++ cur-root/trans.c	2004-07-22 11:07:52.922055672 -0300
@@ -139,22 +139,21 @@ int jtrans_add(struct jtrans *ts, const 
 	pthread_mutex_lock(&(ts->lock));
 	if (ts->op == NULL) {
 		ts->op = malloc(sizeof(struct joper));
+		if (ts->op == NULL)
+			return 0;
 		jop = ts->op;
 		jop->prev = NULL;
 	} else {
 		for (tmpop = ts->op; tmpop->next != NULL; tmpop = tmpop->next)
 			;
 		tmpop->next = malloc(sizeof(struct joper));
+		if (tmpop->next == NULL)
+			return 0;
 		tmpop->next->prev = tmpop;
 		jop = tmpop->next;
 	}
 	pthread_mutex_unlock(&(ts->lock));
 
-	if (jop == NULL) {
-		/* malloc() failed */
-		return 0;
-	}
-
 	jop->buf = malloc(count);
 	if (jop->buf == NULL) {
 		free(jop);
_

