Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: third_party/libxml/src/globals.c

Issue 10458051: Attempt to address libxml crash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/libxml/README.chromium ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * globals.c: definition and handling of the set of global variables 2 * globals.c: definition and handling of the set of global variables
3 * of the library 3 * of the library
4 * 4 *
5 * The bottom of this file is automatically generated by build_glob.py 5 * The bottom of this file is automatically generated by build_glob.py
6 * based on the description file global.data 6 * based on the description file global.data
7 * 7 *
8 * See Copyright for the status of this software. 8 * See Copyright for the status of this software.
9 * 9 *
10 * Gary Pennington <Gary.Pennington@uk.sun.com> 10 * Gary Pennington <Gary.Pennington@uk.sun.com>
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 #undef xmlMemStrdup 79 #undef xmlMemStrdup
80 #undef xmlRealloc 80 #undef xmlRealloc
81 81
82 #if defined(DEBUG_MEMORY_LOCATION) || defined(DEBUG_MEMORY) 82 #if defined(DEBUG_MEMORY_LOCATION) || defined(DEBUG_MEMORY)
83 xmlFreeFunc xmlFree = (xmlFreeFunc) xmlMemFree; 83 xmlFreeFunc xmlFree = (xmlFreeFunc) xmlMemFree;
84 xmlMallocFunc xmlMalloc = (xmlMallocFunc) xmlMemMalloc; 84 xmlMallocFunc xmlMalloc = (xmlMallocFunc) xmlMemMalloc;
85 xmlMallocFunc xmlMallocAtomic = (xmlMallocFunc) xmlMemMalloc; 85 xmlMallocFunc xmlMallocAtomic = (xmlMallocFunc) xmlMemMalloc;
86 xmlReallocFunc xmlRealloc = (xmlReallocFunc) xmlMemRealloc; 86 xmlReallocFunc xmlRealloc = (xmlReallocFunc) xmlMemRealloc;
87 xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup; 87 xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup;
88 #else 88 #else
89
90 #define MAX_LIBXML_MALLOC (1024*1024*512)
91
92 static void* size_checked_malloc(size_t size) {
93 if (size > MAX_LIBXML_MALLOC) {
94 *(volatile char*)0 = '\0';
95 return NULL;
96 }
97 return malloc(size);
98 }
99
100 static void* size_checked_realloc(void* ptr, size_t size) {
101 if (size > MAX_LIBXML_MALLOC) {
102 *(volatile char*)0 = '\0';
103 return NULL;
104 }
105 return realloc(ptr, size);
106 }
107
89 /** 108 /**
90 * xmlFree: 109 * xmlFree:
91 * @mem: an already allocated block of memory 110 * @mem: an already allocated block of memory
92 * 111 *
93 * The variable holding the libxml free() implementation 112 * The variable holding the libxml free() implementation
94 */ 113 */
95 xmlFreeFunc xmlFree = (xmlFreeFunc) free; 114 xmlFreeFunc xmlFree = (xmlFreeFunc) free;
96 /** 115 /**
97 * xmlMalloc: 116 * xmlMalloc:
98 * @size: the size requested in bytes 117 * @size: the size requested in bytes
99 * 118 *
100 * The variable holding the libxml malloc() implementation 119 * The variable holding the libxml malloc() implementation
101 * 120 *
102 * Returns a pointer to the newly allocated block or NULL in case of error 121 * Returns a pointer to the newly allocated block or NULL in case of error
103 */ 122 */
104 xmlMallocFunc xmlMalloc = (xmlMallocFunc) malloc; 123 xmlMallocFunc xmlMalloc = (xmlMallocFunc) size_checked_malloc;
105 /** 124 /**
106 * xmlMallocAtomic: 125 * xmlMallocAtomic:
107 * @size: the size requested in bytes 126 * @size: the size requested in bytes
108 * 127 *
109 * The variable holding the libxml malloc() implementation for atomic 128 * The variable holding the libxml malloc() implementation for atomic
110 * data (i.e. blocks not containings pointers), useful when using a 129 * data (i.e. blocks not containings pointers), useful when using a
111 * garbage collecting allocator. 130 * garbage collecting allocator.
112 * 131 *
113 * Returns a pointer to the newly allocated block or NULL in case of error 132 * Returns a pointer to the newly allocated block or NULL in case of error
114 */ 133 */
115 xmlMallocFunc xmlMallocAtomic = (xmlMallocFunc) malloc; 134 xmlMallocFunc xmlMallocAtomic = (xmlMallocFunc) size_checked_malloc;
116 /** 135 /**
117 * xmlRealloc: 136 * xmlRealloc:
118 * @mem: an already allocated block of memory 137 * @mem: an already allocated block of memory
119 * @size: the new size requested in bytes 138 * @size: the new size requested in bytes
120 * 139 *
121 * The variable holding the libxml realloc() implementation 140 * The variable holding the libxml realloc() implementation
122 * 141 *
123 * Returns a pointer to the newly reallocated block or NULL in case of error 142 * Returns a pointer to the newly reallocated block or NULL in case of error
124 */ 143 */
125 xmlReallocFunc xmlRealloc = (xmlReallocFunc) realloc; 144 xmlReallocFunc xmlRealloc = (xmlReallocFunc) size_checked_realloc;
126 /** 145 /**
127 * xmlMemStrdup: 146 * xmlMemStrdup:
128 * @str: a zero terminated string 147 * @str: a zero terminated string
129 * 148 *
130 * The variable holding the libxml strdup() implementation 149 * The variable holding the libxml strdup() implementation
131 * 150 *
132 * Returns the copy of the string or NULL in case of error 151 * Returns the copy of the string or NULL in case of error
133 */ 152 */
134 xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) xmlStrdup; 153 xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) xmlStrdup;
135 #endif /* DEBUG_MEMORY_LOCATION || DEBUG_MEMORY */ 154 #endif /* DEBUG_MEMORY_LOCATION || DEBUG_MEMORY */
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after
1105 xmlOutputBufferCreateFilenameFunc * 1124 xmlOutputBufferCreateFilenameFunc *
1106 __xmlOutputBufferCreateFilenameValue(void) { 1125 __xmlOutputBufferCreateFilenameValue(void) {
1107 if (IS_MAIN_THREAD) 1126 if (IS_MAIN_THREAD)
1108 return (&xmlOutputBufferCreateFilenameValue); 1127 return (&xmlOutputBufferCreateFilenameValue);
1109 else 1128 else
1110 return (&xmlGetGlobalState()->xmlOutputBufferCreateFilenameValue); 1129 return (&xmlGetGlobalState()->xmlOutputBufferCreateFilenameValue);
1111 } 1130 }
1112 1131
1113 #define bottom_globals 1132 #define bottom_globals
1114 #include "elfgcchack.h" 1133 #include "elfgcchack.h"
OLDNEW
« no previous file with comments | « third_party/libxml/README.chromium ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698