[FFmpeg-devel] [PATCH] tests/checkasm: prevent a segmentation fault when calling strncmp()

Martin Storsjö martin at martin.st
Thu Jan 16 23:03:49 EET 2025


On Thu, 16 Jan 2025, Sean McGovern wrote:

>> This feels like less of an issue with strncmp, and more of an issue with
>> the spec for main() and argc/argv; how do you do to end up with a NULL
>> entry in argv[i] for 0 <= i < argc?
>
> If 'checkasm' is run without arguments, argv[i] would be NULL since argc == 1.

If we have argc == 1, and we run the loop "for (i = 1; i < argc; i++)", it 
will never even enter the loop body, right?

> It only really tripped up on GCC with Address Sanitizer enabled, but
> the comment regarding
> how POSIX does not require a length check on either argument means we should
> be defensive.
>
> In fact, even 'checkasm --test=blah' triggered the segmentation fault
> under ASan.

Sorry, I don't see how that would happen, and I can't reproduce it.

// Martin



More information about the ffmpeg-devel mailing list