Add Apache License version 2.0.
[pbc.git] / guru / param_parse_test.c
bloba345e2c1a5f5b1c1ff1f0be1b0002876de6b8ea1
1 // Exercises a bug reported by Michael Adjedj.
2 //
3 // In ecc/param.c, token_get() would increment a pointer past a terminating
4 // NUL, so the parser would keep attempting to read key/value pairs for a
5 // symbol table. If the memory after the string contains a duplicate key,
6 // then we have a memory leak because we strdup the value and misc/symtab.c
7 // overwrites existing elements during insert.
8 //
9 // Run with valgrind to spot the bug.
10 #include "pbc.h"
12 int main(void) {
13 pairing_t p;
14 pairing_init_set_str(p,
15 "type a\n"
16 "q 8780710799663312522437781984754049815806883199414208211028653399266475630880222957078625179422662221423155858769582317459277713367317481324925129998224791\n"
17 "h 12016012264891146079388821366740534204802954401251311822919615131047207289359704531102844802183906537786776\n"
18 "r 730750818665451621361119245571504901405976559617\n"
19 "exp2 159\n"
20 "exp1 107\n"
21 "sign1 1\n"
22 "sign0 1\0a b a b\n"
24 pairing_clear(p);
25 return 0;