Fixed test to not assume that malloc(10) will return 10 nul bytes!

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4978
This commit is contained in:
Tom Hughes 2005-11-01 17:21:03 +00:00
parent 00774ab311
commit 030b1aac10
4 changed files with 13 additions and 5 deletions

View File

@ -1,9 +1,17 @@
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main ( void )
{
char* arr = malloc(10);
(void) write( 1 /* stdout */, arr, 10 );
int fd = open("/dev/null", O_WRONLY);
if (fd < 0) {
fprintf(stderr, "open failed\n");
} else {
(void)write(fd, arr, 10);
(void)close(fd);
}
return 0;
}

View File

@ -4,4 +4,4 @@ Syscall param write(buf) points to uninitialised byte(s)
by 0x........: ...
Address 0x........ is 0 bytes inside a block of size 10 alloc'd
at 0x........: malloc (vg_replace_malloc.c:...)
by 0x........: main (fwrite.c:6)
by 0x........: main (fwrite.c:7)

View File

@ -1,6 +1,6 @@
Syscall param write(buf) points to uninitialised byte(s)
at 0x........: write (in /...libc...)
by 0x........: main (fwrite.c:7)
by 0x........: main (fwrite.c:12)
Address 0x........ is 0 bytes inside a block of size 10 alloc'd
at 0x........: malloc (vg_replace_malloc.c:...)
by 0x........: main (fwrite.c:6)
by 0x........: main (fwrite.c:7)

Binary file not shown.