Fix bug with panic("out of memory")
authorAndreas Zwinkau <zwinkau@kit.edu>
Mon, 9 Jan 2012 15:39:07 +0000 (16:39 +0100)
committerAndreas Zwinkau <zwinkau@kit.edu>
Mon, 9 Jan 2012 15:42:15 +0000 (16:42 +0100)
The panic function might allocate memory via ir_vfprintf, so we must
not use it in the out of memory case.  Otherwise we get an infinite loop.

ir/adt/xmalloc.c

index 12f2237..4f2ba33 100644 (file)
@@ -35,7 +35,8 @@
 
 static NORETURN xnomem(void)
 {
-       panic("out of memory");
+       /* Do not use panic() here, because it might try to allocate memory! */
+       fputs("out of memory", stderr);
 }
 
 void *xmalloc(size_t size)