Module Name: src Committed By: rillig Date: Sat Mar 13 10:47:59 UTC 2021
Modified Files: src/usr.bin/indent: pr_comment.c Log Message: indent: document undefined behavior in processing of comments No functional change. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/usr.bin/indent/pr_comment.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/indent/pr_comment.c diff -u src/usr.bin/indent/pr_comment.c:1.24 src/usr.bin/indent/pr_comment.c:1.25 --- src/usr.bin/indent/pr_comment.c:1.24 Sat Mar 13 10:32:25 2021 +++ src/usr.bin/indent/pr_comment.c Sat Mar 13 10:47:59 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: pr_comment.c,v 1.24 2021/03/13 10:32:25 rillig Exp $ */ +/* $NetBSD: pr_comment.c,v 1.25 2021/03/13 10:47:59 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -46,7 +46,7 @@ static char sccsid[] = "@(#)pr_comment.c #include <sys/cdefs.h> #ifndef lint #if defined(__NetBSD__) -__RCSID("$NetBSD: pr_comment.c,v 1.24 2021/03/13 10:32:25 rillig Exp $"); +__RCSID("$NetBSD: pr_comment.c,v 1.25 2021/03/13 10:47:59 rillig Exp $"); #elif defined(__FreeBSD__) __FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $"); #endif @@ -186,6 +186,10 @@ pr_comment(void) */ char *start; + /* + * XXX: ordered comparison between pointers from different objects + * invokes undefined behavior (C99 6.5.8). + */ start = buf_ptr >= save_com && buf_ptr < save_com + sc_size ? sc_buf : in_buffer; ps.n_comment_delta = -indentation_after_range(0, start, buf_ptr - 2);