Module Name:    src
Committed By:   christos
Date:           Sun Jul 26 15:53:05 UTC 2020

Modified Files:
        src/lib/libexecinfo: unwind.c

Log Message:
If Unwind_Backtrace is broken, ctx.n will still contain ~0, and we will
return that which poor behavior for the user, so return 0 instead.
We could document ~0 to be an error, but that would deviate from the
Linux behavior which is not desirable. Noted by Poul-Henning Kamp


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libexecinfo/unwind.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libexecinfo/unwind.c
diff -u src/lib/libexecinfo/unwind.c:1.4 src/lib/libexecinfo/unwind.c:1.5
--- src/lib/libexecinfo/unwind.c:1.4	Wed Jan 22 11:07:40 2020
+++ src/lib/libexecinfo/unwind.c	Sun Jul 26 11:53:05 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: unwind.c,v 1.4 2020/01/22 16:07:40 mgorny Exp $	*/
+/*	$NetBSD: unwind.c,v 1.5 2020/07/26 15:53:05 christos Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -67,7 +67,9 @@ backtrace(void **arr, size_t len)
 	ctx.n = (size_t)~0;
 
 	_Unwind_Backtrace(tracer, &ctx);
-	if (ctx.n != (size_t)~0 && ctx.n > 0)
+	if (ctx.n == (size_t)~0)
+		ctx.n = 0;
+	else if (ctx.n > 0)
 		ctx.arr[--ctx.n] = NULL;	/* Skip frame below __start */
 
 	return ctx.n;

Reply via email to