eh_alloc.cc (__cxa_allocate_exception): Don't terminate holding the mutex.
authorNathan Sidwell <nathan@codesourcery.com>
Thu, 12 Apr 2001 07:47:34 +0000 (07:47 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Thu, 12 Apr 2001 07:47:34 +0000 (07:47 +0000)
* libsupc++/eh_alloc.cc (__cxa_allocate_exception): Don't
terminate holding the mutex. Make sure size fits in EMERGENCY_OBJ_SIZE.

From-SVN: r41296

libstdc++-v3/ChangeLog
libstdc++-v3/libsupc++/eh_alloc.cc

index 588e8d8d6b2f87478c7d6e64905aa9b3026da552..50cf9ecb3b255de28c2a341da95a623895f9834d 100644 (file)
@@ -1,3 +1,8 @@
+2001-04-12  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * libsupc++/eh_alloc.cc (__cxa_allocate_exception): Don't
+       terminate holding the mutex. Make sure size fits in EMERGENCY_OBJ_SIZE.
+
 2001-04-12  Gabriel Dos Reis  <gdr@codesourcery.com>
 
        * testsuite/README: Add DejaGnu specific documentation.
index 61dc75d159b1270a6fc95bd879799007bfacf335..bbaa6f694a0cbfadbe07a9862d797908a6e478c9 100644 (file)
@@ -113,19 +113,24 @@ __cxa_allocate_exception(std::size_t thrown_size)
       bitmask_type used = emergency_used;
       unsigned int which = 0;
 
+      if (thrown_size > EMERGENCY_OBJ_SIZE)
+       goto failed;
       while (used & 1)
        {
          used >>= 1;
          if (++which >= EMERGENCY_OBJ_COUNT)
-           std::terminate ();
+           goto failed;
        }
 
       emergency_used |= (bitmask_type)1 << which;
       ret = &emergency_buffer[which][0];
 
+    failed:;
 #ifdef __GTHREADS
       __gthread_mutex_unlock (&emergency_mutex);
 #endif
+      if (!ret)
+       std::terminate ();
     }
 
   memset (ret, 0, sizeof (__cxa_exception));