瀏覽代碼

[hlc] fix hlc_capture_stack not returning total count with empty stack (#773)

Yuxiao Mao 5 月之前
父節點
當前提交
d366212435
共有 1 個文件被更改,包括 8 次插入0 次删除
  1. 8 0
      src/hlc_main.c

+ 8 - 0
src/hlc_main.c

@@ -114,6 +114,14 @@ static uchar *hlc_resolve_symbol( void *addr, uchar *out, int *outSize ) {
 
 
 static int hlc_capture_stack( void **stack, int size ) {
 static int hlc_capture_stack( void **stack, int size ) {
 	int count = 0;
 	int count = 0;
+#	if defined(HL_WIN_DESKTOP) || defined(HL_LINUX) || defined(HL_MAC)
+	// force return total count when output stack is null
+	static void* tmpstack[HL_EXC_MAX_STACK];
+	if( stack == NULL ) {
+		stack = tmpstack;
+		size = HL_EXC_MAX_STACK;
+	}
+#	endif
 #	ifdef HL_WIN_DESKTOP
 #	ifdef HL_WIN_DESKTOP
 	count = CaptureStackBackTrace(2, size, stack, NULL) - 8; // 8 startup
 	count = CaptureStackBackTrace(2, size, stack, NULL) - 8; // 8 startup
 #	elif defined(HL_LINUX)
 #	elif defined(HL_LINUX)