[kaffe] CVS kaffe (dalibor): Check zlib returns for OOM

Kaffe CVS cvs-commits at kaffe.org
Wed Sep 1 15:38:27 PDT 2004


PatchSet 5135 
Date: 2004/09/01 21:53:48
Author: dalibor
Branch: HEAD
Tag: (none) 
Log:
Check zlib returns for OOM

2004-09-01      jrandom <jrandom at i2p.net>

        * kaffe/libraries/clib/zip/Inflater.c:
        (inflate0): Check for memory allocation error.
        (init): Likewise.

        * kaffe/libraries/clib/zip/Deflater.c:
        (deflate): Likewise.
        (init): Likewise.

Members: 
	ChangeLog:1.2691->1.2692 
	libraries/clib/zip/Deflater.c:1.14->1.15 
	libraries/clib/zip/Inflater.c:1.13->1.14 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2691 kaffe/ChangeLog:1.2692
--- kaffe/ChangeLog:1.2691	Wed Sep  1 10:31:03 2004
+++ kaffe/ChangeLog	Wed Sep  1 21:53:48 2004
@@ -1,3 +1,13 @@
+2004-09-01	jrandom <jrandom at i2p.net>
+
+	* kaffe/libraries/clib/zip/Inflater.c: 
+	(inflate0): Check for memory allocation error.
+	(init): Likewise.
+	
+	* kaffe/libraries/clib/zip/Deflater.c: 
+	(deflate): Likewise.
+	(init): Likewise.
+
 2004-09-01  Dalibor Topic  <robilad at kaffe.org>
 
 	* kaffe/kaffevm/kaffe-gc/gc-mem.h (ASSERT_ONBLOCK): 
Index: kaffe/libraries/clib/zip/Deflater.c
diff -u kaffe/libraries/clib/zip/Deflater.c:1.14 kaffe/libraries/clib/zip/Deflater.c:1.15
--- kaffe/libraries/clib/zip/Deflater.c:1.14	Sun Apr 18 13:57:31 2004
+++ kaffe/libraries/clib/zip/Deflater.c	Wed Sep  1 21:53:50 2004
@@ -70,6 +70,13 @@
 		unhand(this)->finished = 1;
 		break;
 
+	case Z_MEM_ERROR:
+		{
+		errorInfo info;
+		postOutOfMemory(&info);
+		throwError(&info);
+		}
+
 	default:
 		SignalError("java.lang.Error", dstream->msg ? dstream->msg : "unknown error");
 	}
@@ -138,6 +145,11 @@
  	z_stream* dstream;
 
 	dstream = KMALLOC(sizeof(*dstream));
+	if (!dstream) {
+		errorInfo info;
+		postOutOfMemory(&info);
+		throwError(&info);
+	}
 	dstream->next_in = 0;
 	dstream->zalloc = kaffe_zalloc;
 	dstream->zfree = kaffe_zfree;
@@ -145,7 +157,18 @@
 
 	r = deflateInit2(dstream, Z_DEFAULT_COMPRESSION, Z_DEFLATED, (val ? -WSIZEBITS : WSIZEBITS), 9, Z_DEFAULT_STRATEGY);
 
-	if (r != Z_OK) {
+	switch (r) {
+	case Z_OK:
+		break;
+
+	case Z_MEM_ERROR:
+		{
+		errorInfo info;
+		postOutOfMemory(&info);
+		throwError(&info);
+		}
+
+	default:
 		SignalError("java.lang.Error", dstream->msg ? dstream->msg : "");
 	}
 
Index: kaffe/libraries/clib/zip/Inflater.c
diff -u kaffe/libraries/clib/zip/Inflater.c:1.13 kaffe/libraries/clib/zip/Inflater.c:1.14
--- kaffe/libraries/clib/zip/Inflater.c:1.13	Sun Apr 18 13:57:31 2004
+++ kaffe/libraries/clib/zip/Inflater.c	Wed Sep  1 21:53:51 2004
@@ -71,6 +71,13 @@
 	case Z_NEED_DICT:
 		unhand(this)->needsDictionary = 1;
 		break;
+	
+	case Z_MEM_ERROR:
+		{
+		errorInfo info;
+                postOutOfMemory(&info);
+                throwError(&info);
+		}
 
 	default:
 		SignalError("java.lang.Error", dstream->msg ? dstream->msg : "unknown error");
@@ -149,7 +156,19 @@
 	dstream->opaque = 0;
 
 	r = inflateInit2(dstream, val ? -WSIZEBITS : WSIZEBITS);
-	if (r != Z_OK) {
+
+	switch (r) {
+        case Z_OK:
+                break;
+	
+	case Z_MEM_ERROR:
+		{
+		errorInfo info;
+                postOutOfMemory(&info);
+                throwError(&info);
+		}
+
+	default:
 		SignalError("java.lang.Error", dstream->msg ? dstream->msg : "");
 	}
 	GET_STREAM(this) = dstream;




More information about the kaffe mailing list