Skip to content

Commit 844a884

Browse files
committed
ensure sufficient data to cover full size banner
1 parent 3ecac41 commit 844a884

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

source/ndscreate.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#include "sha1.h"
1212
#include "crc.h"
1313

14+
#include <algorithm>
15+
1416
unsigned int arm9_align = 0x1FF;
1517
unsigned int arm7_align = 0x1FF;
1618
unsigned int fnt_align = 0x1FF; // 0x3 0x1FF
@@ -692,7 +694,8 @@ void Create()
692694
// Set flags in DSi extended header
693695
if (header.unitcode & 2)
694696
{
695-
newfilesize = (ftell(fNDS) + file_align) & ~file_align;
697+
newfilesize = std::max( ftell(fNDS) , static_cast<long>(header.banner_offset + 0x23c0));
698+
newfilesize = (newfilesize + file_align) & ~file_align;
696699
header.total_rom_size = newfilesize;
697700

698701
if (newfilesize != ftell(fNDS) ) {

0 commit comments

Comments
 (0)