From 823e82e260a80c0e7e15636e1f8da1f9da08c654 Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Sun, 24 Jan 2010 10:13:45 +0000
Subject: [PATCH] Correct UTF-32BE BOM detection in wxConvAuto.

On the fly detection of the BOM was wrongly implemented for UTF-32BE in
r63064 and returned BOM_None for it if we tried to read exactly 2 bytes.

Fix this by returning BOM_Unknown if the first 2 bytes are NUL.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63246 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 src/common/convauto.cpp | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/common/convauto.cpp b/src/common/convauto.cpp
index c684613f4c..dde8af743e 100644
--- a/src/common/convauto.cpp
+++ b/src/common/convauto.cpp
@@ -107,11 +107,13 @@ wxConvAuto::BOMType wxConvAuto::DetectBOM(const char *src, size_t srcLen)
 
             if ( src[0] == '\x00' && src[1] == '\x00' )
             {
-                // this could only be UTF-32BE
-                if ( srcLen == 3 && src[2] == '\xFE' )
-                    return BOM_Unknown;
-            }
+                // this could only be UTF-32BE, check that the data we have so
+                // far allows for it
+                if ( srcLen == 3 && src[2] != '\xFE' )
+                    return BOM_None;
 
+                return BOM_Unknown;
+            }
             break;
 
         default:
-- 
2.47.2