From d50c3575f9612c3adf2a1d732f20df788ffa4e91 Mon Sep 17 00:00:00 2001
From: Rodrigo Braz Monteiro <zeratul@cellosoft.com>
Date: Mon, 21 Jan 2008 22:34:55 +0000
Subject: [PATCH] Fixed crash on charset detection.

Originally committed to SVN as r1811.
---
 aegisub/charset_detect.cpp | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/aegisub/charset_detect.cpp b/aegisub/charset_detect.cpp
index f59d8f26a..f45e91fb2 100644
--- a/aegisub/charset_detect.cpp
+++ b/aegisub/charset_detect.cpp
@@ -69,15 +69,17 @@ wxString CharSetDetect::GetEncoding(wxString filename) {
 	// Grab every result obtained
 	std::list<CharDetResult> results;
 	for (int i=0;i<NUM_OF_CHARSET_PROBERS;i++) {
-		int probes = mCharSetProbers[i]->GetProbeCount();
-		for (int j=0;j<probes;j++) {
-			float conf = mCharSetProbers[i]->GetConfidence(j);
-
-			// Only bother with those whose confidence is at least 1%
-			if (conf > 0.01f) {
-				results.push_back(CharDetResult());
-				results.back().name = wxString(mCharSetProbers[i]->GetCharSetName(j),wxConvUTF8);
-				results.back().confidence = mCharSetProbers[i]->GetConfidence(j);
+		if (mCharSetProbers[i]) {
+			int probes = mCharSetProbers[i]->GetProbeCount();
+			for (int j=0;j<probes;j++) {
+				float conf = mCharSetProbers[i]->GetConfidence(j);
+
+				// Only bother with those whose confidence is at least 1%
+				if (conf > 0.01f) {
+					results.push_back(CharDetResult());
+					results.back().name = wxString(mCharSetProbers[i]->GetCharSetName(j),wxConvUTF8);
+					results.back().confidence = mCharSetProbers[i]->GetConfidence(j);
+				}
 			}
 		}
 	}
-- 
GitLab