Skip to content

Commit

Permalink
Fix undefined behavior about C code in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dinosaure committed Mar 3, 2021
1 parent 73c0e4e commit 7863588
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions test/bin/bindings.t
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ Test reverse bindings
> int main() {
> char i[] = "Hello World!" ;
> char *o = malloc(0x1000) ;
> char *r = malloc(strlen(i)) ;
> char *r = malloc(strlen(i) + 1) ;
>
> memset(o, 0, 0x1000);
> memset(r, 0, strlen(i));
>
> int res0 = decompress_deflate(i, strlen(i), o, 0x1000, 6);
> int res1 = decompress_inflate(o, res0, r, strlen(i));
> int res0 = decompress_deflate(i, strlen(i) + 1, o, 0x1000, 6);
> int res1 = decompress_inflate(o, res0, r, strlen(i) + 1);
>
> printf("%s\n", r);
> fflush(stdout);
Expand All @@ -26,3 +26,4 @@ Test reverse bindings
$ cc -o a.out main.c -I$(ocamlopt -where) -L../../bindings/stubs -I../../bindings/stubs -ldecompress -lm -ldl
$ ./a.out
Hello World!

0 comments on commit 7863588

Please sign in to comment.