Fix handling of images with DOSEMU headers.
diff --git a/NEWS b/NEWS
index 9d6c5a0..2969e89 100644
--- a/NEWS
+++ b/NEWS
@@ -24,6 +24,8 @@
 	* Temporarily disable the idle API call on PXELINUX, due to
 	  some platforms on which the idle API call seems to hang; this
 	  problem has not yet been debugged.
+	* MEMDISK: the handling of DOSEMU-headered images was broken;
+	  fix it.
 
 Changes in 3.09:
 	* gcc4 compilation fix.
diff --git a/memdisk/memdisk.h b/memdisk/memdisk.h
index f728388..302cbbd 100644
--- a/memdisk/memdisk.h
+++ b/memdisk/memdisk.h
@@ -55,7 +55,7 @@
   const unsigned char *__bb = __b;
   int __d;
 
-  while ( __n ) {
+  while ( __n-- ) {
     __d = *__bb++ - *__aa++;
     if ( __d )
       return __d;