Skip to content

Commit a6e59e8

Browse files
committed
Fix incorrect argument in 'do_size' error message
Previously, the error message in 'do_size' referenced 'argv[2]' instead of 'argv[1]'. Since 'argc' is at most 2 in this context, 'argv[2]' is always null, as defined in Section 5.1.2.2.1 of the C11 standard. While GCC prints "(null)" for a null pointer in '%s' formatting, this behavior is implementation-defined. Other compilers may cause undefined behavior, potentially leading to a segmentation fault. This change ensures the correct argument is used, avoiding reliance on implementation-specific behavior and preventing potential crashes. Change-Id: I27748efd7c3d533659a6eda78f7c68ced2e78366
1 parent 122aea9 commit a6e59e8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

qtest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ static bool do_size(int argc, char *argv[])
544544
bool ok = true;
545545
if (argc == 2) {
546546
if (!get_int(argv[1], &reps))
547-
report(1, "Invalid number of calls to size '%s'", argv[2]);
547+
report(1, "Invalid number of calls to size '%s'", argv[1]);
548548
}
549549

550550
int cnt = 0;

0 commit comments

Comments
 (0)