Sophie

Sophie

distrib > Mageia > 5 > x86_64 > media > core-updates-src > by-pkgid > c63dd71a99e4f19f37b981fe7fd81f11 > files > 3

dosfstools-3.0.27-1.1.mga5.src.rpm

diff --git a/src/fat.c b/src/fat.c
index 027c586..2b0d9ce 100644
--- a/src/fat.c
+++ b/src/fat.c
@@ -197,10 +197,12 @@ void set_fat(DOS_FS * fs, uint32_t cluster, int32_t new)
 	    data[1] = new >> 4;
 	} else {
 	    FAT_ENTRY subseqEntry;
-	    get_fat(&subseqEntry, fs->fat, cluster + 1, fs);
+	    if (cluster != fs->clusters - 1)
+		get_fat(&subseqEntry, fs->fat, cluster + 1, fs);
+	    else
+		subseqEntry.value = 0;
 	    data[0] = new & 0xff;
-	    data[1] = (new >> 8) | (cluster == fs->clusters - 1 ? 0 :
-				    (0xff & subseqEntry.value) << 4);
+	    data[1] = (new >> 8) | ((0xff & subseqEntry.value) << 4);
 	}
 	size = 2;
 	break;