|
@@ -93,11 +93,16 @@ __cdecl void relocate ( struct i386_all_regs *ix86 ) {
|
93
|
93
|
/* If last byte that might be used (r_end-1)
|
94
|
94
|
* is in an odd megabyte, round down r_end to
|
95
|
95
|
* the top of the next even megabyte.
|
|
96
|
+ *
|
|
97
|
+ * Make sure that we don't accidentally wrap
|
|
98
|
+ * r_end below 0.
|
96
|
99
|
*/
|
97
|
|
- r_end = ( r_end - 1 ) & ~0xfffff;
|
98
|
|
- DBG ( "...end truncated to %lx "
|
99
|
|
- "(avoid ending in odd megabyte)\n",
|
100
|
|
- r_end );
|
|
100
|
+ if ( r_end >= 1 ) {
|
|
101
|
+ r_end = ( r_end - 1 ) & ~0xfffff;
|
|
102
|
+ DBG ( "...end truncated to %lx "
|
|
103
|
+ "(avoid ending in odd megabyte)\n",
|
|
104
|
+ r_end );
|
|
105
|
+ }
|
101
|
106
|
} else if ( ( r_end - size ) & 0x100000 ) {
|
102
|
107
|
/* If the last byte that might be used
|
103
|
108
|
* (r_end-1) is in an even megabyte, but the
|
|
@@ -108,7 +113,7 @@ __cdecl void relocate ( struct i386_all_regs *ix86 ) {
|
108
|
113
|
* Make sure that we don't accidentally wrap
|
109
|
114
|
* r_end below 0.
|
110
|
115
|
*/
|
111
|
|
- if ( r_end > 0x100000 ) {
|
|
116
|
+ if ( r_end >= 0x100000 ) {
|
112
|
117
|
r_end = ( r_end - 0x100000 ) & ~0xfffff;
|
113
|
118
|
DBG ( "...end truncated to %lx "
|
114
|
119
|
"(avoid starting in odd megabyte)\n",
|