You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Ron Romero <rr...@newsstand.com> on 2003/04/04 18:40:09 UTC

[PATCH] Silently ignore bad Win32 registry "charset" entries

We had a problem where a customer had a bad entry in their Windows Registry,
under "MIME\\Database\\Charset".  This caused Xerces to panic, which aborted
our program.

My proposed change is to silently ignore failures from Reg function calls in
Win32TransService::Win32TransService().  In the patch suggestion below, I
changed the while loops to for loops, and called continue on a bad return
from any Reg function call.

--- Win32TransService.cpp.orig Fri Apr 04 16:28:36 2003
+++ Win32TransService.cpp Wed Apr 02 21:56:40 2003
@@ -271,9 +271,9 @@
     //
     const unsigned int nameBufSz = 1024;
     char nameBuf[nameBufSz + 1];
-    unsigned int subIndex = 0;
+    unsigned int subIndex;
     unsigned long theSize;
-    while (true)
+    for (subIndex = 0;;++subIndex)
     {
         // Get the name of the next key
         theSize = nameBufSz;
@@ -298,7 +298,7 @@
             , KEY_READ
             , &encodingKey))
         {
-
XMLPlatformUtils::panic(XMLPlatformUtils::Panic_NoTransService);
+            continue;
         }
 
         //
@@ -326,7 +326,7 @@
                 , (unsigned char*)&CPId
                 , &theSize) != ERROR_SUCCESS)
             {
-
XMLPlatformUtils::panic(XMLPlatformUtils::Panic_NoTransService);
+                continue;
             }
 
             //
@@ -345,7 +345,7 @@
                     , (unsigned char*)&IEId
                     , &theSize) != ERROR_SUCCESS)
                 {
-
XMLPlatformUtils::panic(XMLPlatformUtils::Panic_NoTransService);
+                    continue;
                 }
 
                 CPMapEntry* newEntry = new CPMapEntry(nameBuf, CPId, IEId);
@@ -355,7 +355,6 @@
 
         // And now close the subkey handle and bump the subkey index
         ::RegCloseKey(encodingKey);
-        subIndex++;
     }
 
     //
@@ -364,9 +363,8 @@
     //  built and add a new entry with this new name and the same id
     //  values we stored for the original.
     //
-    subIndex = 0;
     char aliasBuf[nameBufSz + 1];
-    while (true)
+    for (subIndex = 0;;++subIndex)
     {
         // Get the name of the next key
         theSize = nameBufSz;
@@ -391,7 +389,7 @@
             , KEY_READ
             , &encodingKey))
         {
-
XMLPlatformUtils::panic(XMLPlatformUtils::Panic_NoTransService);
+            continue;
         }
 
         //
@@ -444,7 +442,6 @@
 
         // And now close the subkey handle and bump the subkey index
         ::RegCloseKey(encodingKey);
-        subIndex++;
     }
 
     // And close the main key handle

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org