VC++ fix - use non-standard names for POSIX functions to avoid heap corruption.

This commit is contained in:
Michael R Sweet 2007-12-06 06:07:50 +00:00
parent 7ac92e8bf8
commit 5115ffdbd1
2 changed files with 21 additions and 5 deletions

View File

@ -26,6 +26,24 @@
#define _CRT_SECURE_NO_DEPRECATE
/*
* Microsoft also renames the POSIX functions to _name, and introduces
* a broken compatibility layer using the original names. As a result,
* random crashes can occur when, for example, strdup() allocates memory
* from a different heap than used by malloc() and free().
*
* To avoid moronic problems like this, we #define the POSIX function
* names to the corresponding non-standard Microsoft names.
*/
#define close _close
#define open _open
#define read _read
#define snprintf _snprintf
#define strdup _strdup
#define vsnprintf _vsnprintf
#define write _write
/*
* Include necessary headers...
@ -42,7 +60,7 @@
* Version number...
*/
#define MXML_VERSION "Mini-XML v2.4"
#define MXML_VERSION "Mini-XML v2.4.1"
/*
@ -56,8 +74,8 @@
* Do we have the snprintf() and vsnprintf() functions?
*/
/*#undef HAVE_SNPRINTF */
/*#undef HAVE_VSNPRINTF */
#define HAVE_SNPRINTF 1
#define HAVE_VSNPRINTF 1
/*

View File

@ -1,8 +1,6 @@
LIBRARY "MXML1"
EXPORTS
_mxml_snprintf
_mxml_strdupf
_mxml_vsnprintf
_mxml_vstrdupf
mxml_ignore_cb
mxml_integer_cb