12. cppcheck Ruby
6
[hash.c:2351]: (error) Memory leak: str
[io.c:5264]: (error) fflush() called on input stream "stdin" may
result in undefined behaviour
[regcomp.c:5524]: (error) Memory leak: new_reg
[vm_dump.c:831]: (error) Possible null pointer dereference: vm -
otherwise it is redundant to check if vm is null at line 778
[vm_dump.c:834]: (error) Possible null pointer dereference: vm -
otherwise it is redundant to check if vm is null at line 778
[vm_dump.c:835]: (error) Possible null pointer dereference: vm -
otherwise it is redundant to check if vm is null at line 778
14. io.c
[io.c:5264]: (error) fflush() called on input stream
"stdin" may result in undefined behaviour
5264 fflush(stdin); /* is it really needed? */
Q. How can I flush pending input so that a user's
typeahead isn't read at the next prompt? Will
fflush(stdin) work?
A. fflush is defined only for output streams. (omit)
comp.lang.c FAQ list · Question 12.26a
15. splint
• written in C
•
• annotation
• cppcheck
•
• cont.c gc.c random.c thread_pthread.h
http://www.splint.org/
16. splint hash.c
• ruby-1.9 trunk revision 33685 (2011-11-09 )
• 397
• header
• Solaris Solaris configure
• cppcheck hash.c
x86
27. Frama-C
• with CIL OCaml
•C
•
•
• value plug-in ←
• users plug-in
http://frama-c.com/
28. division by zero
void foo(int x, int y)
{
int z = x / y; /* y should not be zero */
return;
}
int main(int argc, char **argv)
{
int x = 1, y = 0;
foo(x, y);
return 0;
}
29. Frama-C value plug-in
% frama-c -val foo.c
[value] Analyzing a complete application starting at main
foo.c:3:[kernel] warning: division by zero: assert y ≢ 0;
30. division by zero
• ruby trunk revision no. 33685
• bignum.c
• 1044 ds[k] = (BDIGIT)(num / hbase);
• util.c
•
• 331 n = (r - l + size) / size;
Frama-C value plugin