[Baypiggies] ctypes presentation material online

Stephen McInerney spmcinerney at hotmail.com
Fri May 12 21:05:14 CEST 2006

The case below is a good argument for static type checking?
Is there any type checker smart enough to understand that
string + 1 is unlikely to have semantic meaning.
(I know this is C but the concept is generic.)

>From: Marilyn Davis <marilyn at deliberate.com>
>Yeh.  Memory bugs are just terrible to find.
>I once had one in C code where I was mallocing space for a new string:
>buf = malloc(len(string + 1));
>My eyeball looked at that a jillion times before I realized that I had
>a misplaced ')' and it should be:
>buf = malloc(len(string) + 1);
>The problem is that it crashed much later, after I wrote to the space
>(and overwrote the memory), and then it finally crashed in another
>call to malloc.

More information about the Baypiggies mailing list