Index: C:/gdal/frmts/jpeg/jpgdataset.cpp
===================================================================
--- C:/gdal/frmts/jpeg/jpgdataset.cpp	(revision 10968)
+++ C:/gdal/frmts/jpeg/jpgdataset.cpp	(working copy)
@@ -404,10 +404,13 @@
 
     if (bSwabflag)
         TIFFSwabShort(&nEntryCount);
+        
+    if (nEntryCount == 0)
+		return CE_Failure;
 
     poTIFFDir = (TIFFDirEntry *)CPLMalloc(nEntryCount * sizeof(TIFFDirEntry));
 
-    if (poTIFFDir == NULL) 
+    if (poTIFFDir == NULL)
         CPLError( CE_Failure, CPLE_AppDefined,
                   "No space for TIFF directory");
   
Index: C:/gdal/gcore/gdal_misc.cpp
===================================================================
--- C:/gdal/gcore/gdal_misc.cpp	(revision 10968)
+++ C:/gdal/gcore/gdal_misc.cpp	(working copy)
@@ -1426,6 +1426,28 @@
 
         return TRUE;
     }
+    // Allow for blank spaces between lines.  Many world file writers do this now.
+    else if( CSLCount(papszLines) >= 11
+        && (atof(papszLines[0]) != 0.0 || atof(papszLines[4]) != 0.0)
+        && (atof(papszLines[6]) != 0.0 || atof(papszLines[2]) != 0.0) )
+    {
+        padfGeoTransform[0] = atof(papszLines[8]);
+        padfGeoTransform[1] = atof(papszLines[0]);
+        padfGeoTransform[2] = atof(papszLines[4]);
+        padfGeoTransform[3] = atof(papszLines[10]);
+        padfGeoTransform[4] = atof(papszLines[2]);
+        padfGeoTransform[5] = atof(papszLines[6]);
+
+        // correct for center of pixel vs. top left of pixel
+        padfGeoTransform[0] -= 0.5 * padfGeoTransform[1];
+        padfGeoTransform[0] -= 0.5 * padfGeoTransform[2];
+        padfGeoTransform[3] -= 0.5 * padfGeoTransform[4];
+        padfGeoTransform[3] -= 0.5 * padfGeoTransform[5];
+
+        CSLDestroy(papszLines);
+
+        return TRUE;
+    }
     else
     {
         CPLDebug( "GDAL", 
