mirror of
https://github.com/adtools/clib2.git
synced 2025-12-08 14:59:05 +00:00
- Added the test program for the sprintf() buffer flush bug, courtesy of
Jens Langner. git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14725 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
25
test_programs/sprintf_test.c
Normal file
25
test_programs/sprintf_test.c
Normal file
@ -0,0 +1,25 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
static char buf[256];
|
||||
|
||||
void addsomething(void)
|
||||
{
|
||||
char *p = &buf[strlen(buf)];
|
||||
sprintf(p, "yeah");
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
buf[0] = '\0';
|
||||
|
||||
addsomething();
|
||||
printf("1: [%s]\n", buf);
|
||||
|
||||
sprintf(buf, "");
|
||||
|
||||
addsomething();
|
||||
printf("2: [%s]\n", buf);
|
||||
|
||||
return (0);
|
||||
}
|
||||
Reference in New Issue
Block a user