Created
February 13, 2026 13:47
-
-
Save pmatos/a01a86770caf0252bfb490608a4ec2dd to your computer and use it in GitHub Desktop.
Demo C program with subtle bugs for ESBMC Claude Code plugin verification
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdlib.h> | |
| // Bug 1: off-by-one in the loop bound — writes past the end of buf[] | |
| // Bug 2: missing NULL check after malloc — dereferences a potentially NULL pointer | |
| int main() { | |
| int buf[10]; | |
| for (int i = 0; i <= 10; i++) | |
| buf[i] = i * 2; | |
| int *p = malloc(sizeof(int)); | |
| *p = buf[9] + 1; | |
| int total = 0; | |
| for (int i = 0; i < 10; i++) | |
| total += buf[i]; | |
| free(p); | |
| return total; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment