1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

builtin: add sanity check on the number of returned frames by C.backtrace

This commit is contained in:
Delyan Angelov
2020-08-06 19:50:25 +03:00
parent 3a461e7cee
commit 4568ce8f00
2 changed files with 17 additions and 1 deletions

View File

@@ -103,10 +103,14 @@ $if msvc {
syminitok := C.SymInitialize( handle, 0, 1)
if syminitok != 1 {
eprintln('Failed getting process: Aborting backtrace.\n')
return true
return false
}
frames := int(C.CaptureStackBackTrace(skipframes + 1, 100, backtraces, 0))
if frames < 2 {
eprintln('C.CaptureStackBackTrace returned less than 2 frames')
return false
}
for i in 0..frames {
frame_addr := backtraces[i]
if C.SymFromAddr(handle, frame_addr, &offset, si) == 1 {