=== modified file 'src/TagLib/Id3v2/Frames/TextIdentificationFrame.cs'
--- src/TagLib/Id3v2/Frames/TextIdentificationFrame.cs	2008-01-10 01:30:11 +0000
+++ src/TagLib/Id3v2/Frames/TextIdentificationFrame.cs	2009-03-04 04:51:12 +0000
@@ -867,14 +867,11 @@
 				string value = data.ToString (encoding, 1,
 					data.Count - 1);
 				
-				// Do a fast removal of end bytes.
-				if (value.Length > 1 &&
-					value [value.Length - 1] == 0)
-					for (int i = value.Length - 1; i >= 0; i --)
-						if (value [i] != 0) {
-							value = value.Substring (0, i + 1);
-							break;
-						}
+				// Truncate values containing NULL bytes
+				int null_index = value.IndexOf ('\x00');
+				if (null_index >= 0) {
+					value = value.Substring (0, null_index);
+				}
 				
 				if (FrameId == FrameType.TCOM ||
 					FrameId == FrameType.TEXT ||

=== modified file 'tests/fixtures/TagLib.Tests.FileFormats/Id3V2FormatTest.cs'
--- tests/fixtures/TagLib.Tests.FileFormats/Id3V2FormatTest.cs	2007-12-30 02:50:29 +0000
+++ tests/fixtures/TagLib.Tests.FileFormats/Id3V2FormatTest.cs	2009-03-04 04:51:12 +0000
@@ -8,6 +8,7 @@
     public class Id3V2FormatTest : IFormatTest
     {
         private static string sample_file = "samples/sample_v2_only.mp3";
+        private static string corrupt_file = "samples/corrupt/null_title_v2.mp3";
         private static string tmp_file = "samples/tmpwrite_v2_only.mp3";
         private File file;
         
@@ -43,6 +44,19 @@
             StandardTests.WriteStandardTags (sample_file, tmp_file);
         }
         
+        [Test] // http://bugzilla.gnome.org/show_bug.cgi?id=558123
+        public void TestTruncateOnNull ()
+        {
+            if (System.IO.File.Exists (tmp_file)) {
+                System.IO.File.Delete (tmp_file);
+            }
+            
+            System.IO.File.Copy (corrupt_file, tmp_file);
+            File tmp = File.Create (tmp_file);
+            
+            Assert.AreEqual ("T", tmp.Tag.Title);
+        }
+        
         [Test]
         public void TestCorruptionResistance()
         {

