PreFAST is a great static analysis tool that can find lots of bugs for you; however, sometimes it can act like an over protective mother. In my last posts I NULL terminated the strings just to make PreFAST happy, but it felt more like a hack. I don't like leaving hacks in my real code. If there is a PreFAST warning that you feel like is unjustified and you would like you code to PreFAST warning free, you can use a handy #pragma trick to tell PreFAST that you know what you are doing and its okay. Keep in mind you don't want to do this very often, because generally PreFAST warnings should be fixed.
In my case, I was mallocing a buffer for a string that was to be read from the registry. PreFAST was warning me that I should NULL terminate the string. In this case RegEnumValue should do that correctly or give me an error. Since this warning is safe to ignore and I don't want to put in a hack just to get rid of the warning I added this #pragma at the line where the warning was:
#pragma prefast(suppress: 26036, "We expect that RegEnumValue will properly NULL terminate ppszKeyValue.")