The latest Solaris Studio Express release contains the tool discover, which tests for memory access errors. These are errors like reading past the end of an array or freeing a pointer twice. The best part of the tool is that it does not require a special build of the application. The sequence is:
$ discover a.out $ a.out
discover command adds instrumentation to the executable, and you then run the resulting binary in the same way that you would normally run your program. The output from discover is an html file containing details of any memory access errors that the tool discovered.