nintendoswitch: Fix invalid memory read / write in print calls
Этот коммит содержится в:
родитель
f20c932bb9
коммит
0b9b293651
2 изменённых файлов: 8 добавлений и 17 удалений
|
@ -40,21 +40,18 @@ func ticks() timeUnit {
|
|||
return timeUnit(ticksToNanoseconds(timeUnit(getArmSystemTick())))
|
||||
}
|
||||
|
||||
var stdoutBuffer = make([]byte, 0, 120)
|
||||
var stdoutBuffer = make([]byte, 120)
|
||||
var position = 0
|
||||
|
||||
func putchar(c byte) {
|
||||
if c == '\n' || len(stdoutBuffer)+1 >= 120 {
|
||||
NxOutputString(string(stdoutBuffer))
|
||||
stdoutBuffer = stdoutBuffer[:0]
|
||||
if c == '\n' || position > len(stdoutBuffer) {
|
||||
nxOutputString(&stdoutBuffer[0], uint64(position))
|
||||
position = 0
|
||||
return
|
||||
}
|
||||
|
||||
stdoutBuffer = append(stdoutBuffer, c)
|
||||
}
|
||||
|
||||
func usleep(usec uint) int {
|
||||
sleepThread(uint64(usec) * 1000)
|
||||
return 0
|
||||
stdoutBuffer[position] = c
|
||||
position++
|
||||
}
|
||||
|
||||
func abort() {
|
||||
|
|
|
@ -4,17 +4,11 @@
|
|||
|
||||
package runtime
|
||||
|
||||
import "unsafe"
|
||||
|
||||
const heapSize = 0x2000000 * 16 // Default by libnx
|
||||
|
||||
//go:extern _stack_top
|
||||
var stackTopSymbol [0]byte
|
||||
|
||||
var (
|
||||
heapStart = uintptr(0)
|
||||
heapEnd = uintptr(0)
|
||||
stackTop = uintptr(unsafe.Pointer(&stackTopSymbol))
|
||||
)
|
||||
|
||||
//export setHeapSize
|
||||
|
@ -24,7 +18,7 @@ func preinit() {
|
|||
setHeapSize(&heapStart, heapSize)
|
||||
|
||||
if heapStart == 0 {
|
||||
panic("failed to allocate heap")
|
||||
runtimePanic("failed to allocate heap")
|
||||
}
|
||||
|
||||
heapEnd = heapStart + heapSize
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче