home *** CD-ROM | disk | FTP | other *** search
- /*
- * WriteErr.cpp
- * $Header: /BoundsChecker/Examples/BUGBNCHX/MAINERR/WRITEERR.CPP 5 12/13/96 1:51p Stevea $
- *
- * Description:
- * Write Check error functions.
- *
- * Notes:
- * <implementation notes go here>
- *
- ***********************************************************************
- *
- * Nu-Mega Technologies, Inc.
- * P.O. Box 7780
- * Nashua, NH 03060
- *
- * (c) Copyright 1994, 1995 Nu-Mega Technologies, Inc.
- * ALL RIGHTS RESERVED.
- *
- ***********************************************************************
- *
- **********************************************************************/
- #include "stdafx.h"
- #include "WriteErr.h"
- #include "BCError.h"
-
- // Write Check - Dynamic memory overrun
- void Write_DynMemOverrun ( )
- {
- // If we are in the middle of doing all errors, we don't want to
- // do this function!
- if ( TRUE == DoingAllErrors ( ) )
- {
- return ;
- }
-
- _TRY
- {
- TCHAR * szString = new TCHAR [ 10 ] ;
- _tcscpy ( szString , _T ( "012345678910" ) ) ;
- delete [] szString ;
- }
- _CATCH
- {
- }
- }
- // Write Check - Stack memory overrun
- void Write_StackMemOverrun ( )
- {
- // If we are in the middle of doing all errors, we don't want to
- // do this function!
- if ( TRUE == DoingAllErrors ( ) )
- {
- return ;
- }
-
- _TRY
- {
- TCHAR szExtraSpaceOne[ 3 ] ;
- TCHAR szBuff [ 10 ] ;
- TCHAR szSaveOurStack[ 3 ] ;
- szExtraSpaceOne[ 0 ] = _T ( '\0' ) ;
- szSaveOurStack[ 0 ] = _T ( '\0' ) ;
- _tcscpy ( szBuff , _T ( "01234567891" ) ) ;
- }
- _CATCH
- {
- }
- }
- // Write Check - Static memory overrun
- static TCHAR g_szStaticMem[ 10 ] ;
- void Write_StaticMemOverrun ( )
- {
- // If we are in the middle of doing all errors, we don't want to
- // do this function!
- if ( TRUE == DoingAllErrors ( ) )
- {
- return ;
- }
-
- _TRY
- {
- _tcscpy ( g_szStaticMem , _T ( "0123456789" ) ) ;
- }
- _CATCH
- {
- }
- }
- // Write Check - Writing overflows memory
- void Write_WriteOverflowsMem ( )
- {
- _TRY
- {
- char szExtraSpace1[ 10 ] ;
- char szBuff[ 9 ] ;
- char szExtraSpace2[ 10 ] ;
-
- // Generate error
- *(szBuff + 12) = 5;
-
- // Get rid of the CL warnings
- szExtraSpace1[ 0 ] = '\0' ;
- szExtraSpace2[ 0 ] = '\0' ;
-
- }
- _CATCH
- {
- }
- }
-