On Thu, Jun 2, 2011 at 11:38 AM, Ronald Burgman < [email protected]> wrote:
> Hi, > > I've found a strange piece of code. The print_stack_union function > allocates some memory to the types variable (line 3436) and terminates > with an error code if this allocation fails (line 3450). But types is > already accessed before this check. So shouldn't the check be earlier > in the code, or am I missing something? > http://www.sqlite.org/src/ci/efb20b9da6 Note, however, that lemon.c is not a deliverable component of SQLite, but rather a code generator program that generates some of the C code for SQLite, and lemon always runs on a workstation, and so it is essentially impossible for the calloc() to fail since modern workstations do not fail mallocs. So this is not a real bug. But it is worth patching, all the same. Thanks. > > Cheers, > Ronald > > 3436: types = (char**)calloc( arraysize, sizeof(char*) ); > for(i=0; i<arraysize; i++) types[i] = 0; > maxdtlength = 0; > if( lemp->vartype ){ > maxdtlength = lemonStrlen(lemp->vartype); > } > for(i=0; i<lemp->nsymbol; i++){ > int len; > struct symbol *sp = lemp->symbols[i]; > if( sp->datatype==0 ) continue; > len = lemonStrlen(sp->datatype); > if( len>maxdtlength ) maxdtlength = len; > } > stddt = (char*)malloc( maxdtlength*2 + 1 ); > 3450: if( types==0 || stddt==0 ){ > fprintf(stderr,"Out of memory.\n"); > exit(1); > } > _______________________________________________ > sqlite-users mailing list > [email protected] > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > -- D. Richard Hipp [email protected] _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

