--- /usr/share/perl5/MythTV.pm	2007-11-10 02:37:44.000000000 +1300
+++ MythTV.pm	2007-11-22 07:27:40.000000000 +1300
@@ -292,7 +292,15 @@
             return;
         }
     # Read the response header to find out how much data we'll be grabbing
-        read($$fp, $length, 8);
+        my $result = read($$fp, $length, 8);
+        if (! defined $result) {
+          warn "Error reading from MythTV backend: $!\n";
+          return "";
+        }  elsif ($result == 0) {
+          warn "No data returned by MythTV backend.\n";
+          return "";
+        }
+
         $length = int($length);
     # Read and return any data that was returned
         $ret = '';
