# # Examples of condates # condate new_deref { from "%X = operator new(%_)" # any new to "%_ = %X->%_" or "%X->%_ = %_" or "*%X = %_" or "%_ = *%X" avoid "%X = %_" or +"%X != 0B" or -"%X == 0B" } warning("Unsafe dereference of X after new"); condate undeleted { from "%X = operator new(%_)" to "return" or "return %_" avoid "operator delete(%X)" or +"%X == 0B" or -"%X != 0B" } warning("Un-deleted memory for variable X"); condate missing_unlock { from "flockfile (%X)" to ("return" or "return %_") avoid "funlockfile (%X)" } warning("Unreleased lock on file X"); condate missing_tryunlock { from "%L = ftrylockfile (%X)" to ("return" or "return %_") avoid "funlockfile (%X)" or +"%L != 0" or -"%L == 0" } warning("Unreleased (successful) trylock on file X"); condate gets { # "degenerate" condate, of only one pattern # 'from' keyword must be omitted: "%X = gets(%Y)" or "gets(%Y)" } warning("Never use gets(), see man gets");