Sun Nov 28 12:20:16 ART 2004  Alberto Bertogli (albertogli@telpin.com.ar)
  * Remove failed operations from the list.
  
  If joper_add() fails when malloc()ing buffer memory, it returns 0 but never
  removes the operation from the list, which could break and/or cause
  corruption. The fix is just to allocate under the lock, and remove the
  operation from the list if the allocation fails.
  
  
diff -rN -u old-libjio/trans.c new-libjio/trans.c
--- old-libjio/trans.c	2005-03-10 15:15:10.185856458 -0300
+++ new-libjio/trans.c	2005-03-10 15:15:10.249849580 -0300
@@ -167,14 +167,22 @@
 		tmpop->next->prev = tmpop;
 		jop = tmpop->next;
 	}
-	pthread_mutex_unlock(&(ts->lock));
 
 	jop->buf = malloc(count);
 	if (jop->buf == NULL) {
+		/* remove from the list and fail */
+		if (jop->prev == NULL) {
+			ts->op = NULL;
+		} else {
+			jop->prev->next = jop->next;
+		}
 		free(jop);
+		pthread_mutex_unlock(&(ts->lock));
 		return 0;
 	}
 
+	pthread_mutex_unlock(&(ts->lock));
+
 	/* we copy the buffer because then the caller can reuse it */
 	memcpy(jop->buf, buf, count);
 	jop->len = count;


