1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-01-28 17:47:00 +03:00

82 Commits

Author SHA1 Message Date
Nick Wellnhofer
40483d0ce2 Deprecate module init and cleanup functions
These functions shouldn't be part of the public API. Most init
functions are only thread-safe when called from xmlInitParser. Global
variables should only be cleaned up by calling xmlCleanupParser.
2022-03-06 15:59:43 +01:00
Nick Wellnhofer
ebb1797030 Remove unneeded #includes 2022-03-04 22:11:49 +01:00
Nick Wellnhofer
72119afe00 Don't check for standard C89 library functions
Don't check for

- fprintf
- localtime
- printf
- rand
- sprintf
- srand
- sscanf
- strftime
- time
- vfprintf
- vsprintf

If the C99 functions snprintf and vsnprintf are missing, Trio is
enabled.
2022-03-02 01:14:08 +01:00
Nick Wellnhofer
776d15d383 Don't check for standard C89 headers
Don't check for

- ctype.h
- errno.h
- float.h
- limits.h
- math.h
- signal.h
- stdarg.h
- stdlib.h
- string.h
- time.h

Stop including non-standard headers

- malloc.h
- strings.h
2022-03-02 00:43:54 +01:00
Nick Wellnhofer
346c3a930c Remove elfgcchack.h
The same optimization can be enabled with -fno-semantic-interposition
since GCC 5. clang has always used this option by default.
2022-02-20 21:49:04 +01:00
Nick Wellnhofer
f4a74bf0ae Add suffix to unsigned constant in xmlmemory.c
Avoids an integer conversion warning with UBSan.
2022-01-25 03:07:30 +01:00
Nick Wellnhofer
20c60886e4 Fix typos
Resolves #133.
2020-03-08 17:41:53 +01:00
Nick Wellnhofer
d422b954be Fix pointer/int cast warnings on 64-bit Windows
On 64-bit Windows, `long` is 32 bits wide and can't hold a pointer.
Switch to ptrdiff_t instead which should be the same size as a pointer
on every somewhat sane platform without requiring C99 types like
intptr_t.

Fixes bug 788312.

Thanks to J. Peter Mugaas for the report and initial patch.
2017-10-09 13:47:49 +02:00
Nick Wellnhofer
1a595cd173 Fix cast-align warnings
- Suppress warnings in xmlmemory.c by casting to 'void *'.
- Remove unneeded cast in xmlschemas.c that caused a macro precedence
  error.
- Add dummy fields to short structs in xmlschemas.c. This increases the
  size of the structs, but I can't see a better solution without using
  C11's _Alignof operator.

There are still a couple of cast-align warnings in encoding.c. These
are legitimate portability issues that can't be fixed without reworking
the conversion functions.
2017-06-17 14:17:27 +02:00
Nick Wellnhofer
ed48d65b4d Fix copy-paste errors in error messages
Thanks to David Kilzer for the review.
2017-06-11 17:12:21 +02:00
Nick Wellnhofer
897dffbae3 Check for integer overflow in memory debug code
Fixes bug 783026.

Thanks to Pranjal Jumde for the report.
2017-06-06 13:21:14 +02:00
David Kilzer
886529b56c Unsigned addition may overflow in xmlMallocAtomicLoc()
For https://bugzilla.gnome.org/show_bug.cgi?id=764616

This code is used only if turning memory allocation debug
in configure with --with-mem-debug, which should never happen
in real life, so not a serious issue.

* xmlmemory.c:
(MAX_SIZE_T): Macro to define maximum value of size_t.
(xmlMallocAtomicLoc): Add bounds check.  Fix description and use
the correct function name in another error message.
2016-05-23 09:23:22 +08:00
Martin von Gagern
8985cde709 xmlMemUsed is not thread-safe
For https://bugzilla.gnome.org/show_bug.cgi?id=747437
just use the mutex to protect access to those variables
2015-04-13 16:32:14 +08:00
Yegor Yefremov
7446445dec xmlmemory: handle realloc properly
If realloc fails, free original pointer.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
2014-10-13 20:46:37 +08:00
Gaurav Gupta
b8480ae781 Remove a couple of dead conditions
For https://bugzilla.gnome.org/show_bug.cgi?id=733711
2014-07-26 21:14:53 +08:00
Gaurav
7966a761b7 Avoid Possible null pointer dereference in memory debug mode
Fix a use before check on pointer
For https://bugzilla.gnome.org/show_bug.cgi?id=729849
2014-05-09 17:00:08 +08:00
Daniel Veillard
f8e3db0445 Big space and tab cleanup
Remove all space before tabs and space and tabs at end of lines.
2012-09-11 13:26:36 +08:00
Stefan Kost
ecb5d5afdc xmlmemory: add a cast as size_t has no portable printf modifier
Also use %lu as that is more appropriate for size_t.
2011-05-09 11:49:52 +03:00
Daniel Veillard
f63085de5e port patch from Marcus Meissner to add gcc checking for printf like
* include/libxml/parser.h include/libxml/xmlwriter.h
  include/libxml/relaxng.h include/libxml/xmlversion.h.in
  include/libxml/xmlwin32version.h.in include/libxml/valid.h
  include/libxml/xmlschemas.h include/libxml/xmlerror.h:
  port patch from Marcus Meissner to add gcc checking for
  printf like functions parameters, should fix #65068
* doc/apibuild.py doc/*: modified the script accordingly
  and regenerated
* xpath.c xmlmemory.c threads.c: fix a few warnings
Daniel

svn path=/trunk/; revision=3813
2009-01-18 20:53:59 +00:00
Daniel Veillard
09459bf107 add xmlMemDisplayLast to help debug incremental memory leaks, and some
* include/libxml/xmlmemory.h xmlmemory.c: add xmlMemDisplayLast to
  help debug incremental memory leaks, and some cleanups
* runxmlconf.c: use that new call and avoid ever touching the
  system catalog in the regression tests
Daniel

svn path=/trunk/; revision=3760
2008-07-30 12:58:11 +00:00
Daniel Veillard
2a512dac2d xmlFree(NULL) should not crash in debug mode should fix #491651 Daniel
* xmlmemory.c: xmlFree(NULL) should not crash in debug mode
  should fix #491651
Daniel

svn path=/trunk/; revision=3662
2007-10-30 20:24:40 +00:00
Daniel Veillard
f4721d66fc fix comment on versions do not spend too much time digging in dumped
* include/libxml/xmlversion.h.in: fix comment on versions
* xmlmemory.c: do not spend too much time digging in dumped memory
Daniel
2006-10-11 21:12:10 +00:00
Daniel Veillard
942d6c7b4f fixed #169630 segfault in xmlMemDisplay Daniel
* xmlmemory.c: fixed #169630 segfault in xmlMemDisplay
Daniel
2005-05-08 11:39:56 +00:00
Daniel Veillard
18ffe20c9e added the call to the breakpoint routine when a monitored block is
* xmlmemory.c: added the call to the breakpoint routine
  when a monitored block is reallocated or freed
Daniel
2005-04-14 17:50:59 +00:00
Daniel Veillard
5d4644ef6e revamped the elfgcchack.h format to cope with gcc4 change of aliasing
* doc/apibuild.py doc/elfgcchack.xsl: revamped the elfgcchack.h
  format to cope with gcc4 change of aliasing allowed scopes, had
  to add extra informations to doc/libxml2-api.xml to separate
  the header from the c module source.
* *.c: updated all c library files to add a #define bottom_xxx
  and reimport elfgcchack.h thereafter, and a bit of cleanups.
* doc//* testapi.c: regenerated when rebuilding the API
Daniel
2005-04-01 13:11:58 +00:00
Daniel Veillard
91b955c1af fixed ID deallocation problem based on patch from Steve Shepard fixes bug
* valid.c: fixed ID deallocation problem based on patch from
  Steve Shepard fixes bug #160893
* xmlmemory.c: improving comment.
* testapi.c: new test for xmlDictExists() is generated.
Daniel
2004-12-10 10:26:42 +00:00
Daniel Veillard
36e5cd5064 adding xmlMemBlocks() work on generator of an automatic API regression
* xmlmemory.c include/libxml/xmlmemory.h: adding xmlMemBlocks()
* Makefile.am gentest.py testapi.c: work on generator of an
  automatic API regression test tool.
* SAX2.c nanoftp.c parser.c parserInternals.c tree.c xmlIO.c
  xmlstring.c: various API hardeing changes as a result of running
  teh first set of automatic API regression tests.
* test/slashdot16.xml: apparently missing from CVS, commited it
Daniel
2004-11-02 14:52:23 +00:00
William M. Brack
13dfa87e91 added the routine xmlNanoHTTPContentLength to the external API
* nanohttp.c, include/libxml/nanohttp.h: added the routine
  xmlNanoHTTPContentLength to the external API (bug151968).
* parser.c: fixed unnecessary internal error message (bug152060);
  also changed call to strncmp over to xmlStrncmp.
* encoding.c: fixed compilation warning (bug152307).
* tree.c: fixed segfault in xmlCopyPropList (bug152368); fixed
  a couple of compilation warnings.
* HTMLtree.c, debugXML.c, xmlmemory.c: fixed a few compilation
  warnings; no change to logic.
2004-09-18 04:52:08 +00:00
Daniel Veillard
e15df587d6 applied a small fix from Steve Hay Daniel
* xmlmemory.c: applied a small fix from Steve Hay
Daniel
2004-07-13 15:25:08 +00:00
Daniel Veillard
529233ccdd some updates with memory debugging facilities while messing with libxslt
* xmlmemory.c python/libxml.c python/libxml2-python-api.xml:
  some updates with memory debugging facilities while messing
  with libxslt python bindings
Daniel
2004-07-02 12:23:44 +00:00
Daniel Veillard
f93a866079 applied patch from Stphane Bidoul to fix some Python bindings
* python/libxml.c python/generator.py python/libxml.py
  python/libxml2-python-api.xml python/libxml2class.txt:
  applied patch from Stphane Bidoul to fix some Python bindings
  initialization, then had to change the parserCleanup()
  to handle memory released there.
* xmlmemory.c: added more debugging comments.
Daniel
2004-07-01 12:56:30 +00:00
William M. Brack
5ab479b0e4 fixed problem when configuring using --with-thread-alloc
* configure.in, xmlmemory.c, globals.c: fixed problem when
  configuring using --with-thread-alloc
2004-06-10 13:00:15 +00:00
Aleksey Sanin
e9f0811a2f make xmlReallocLoc() accept NULL pointer 2004-01-22 22:20:31 +00:00
William M. Brack
9202942ba3 applied suggestion from Miloslav Trmac (see Bug 130419) and eliminated
* xmlmemory.c: applied suggestion from Miloslav Trmac (see
  Bug 130419) and eliminated xmlInitMemoryDone.  More
  improvement needed.

* xml2-config.in: added an additional flag (--exec-prefix) to
  allow library directory to be different from include directory
  (Bug 129558).
2004-01-04 01:01:14 +00:00
Daniel Veillard
1a9b7084f6 found and fixed a bug misallocating some non blank text node strings from
* SAX2.c: found and fixed a bug misallocating some non
  blank text node strings from the dictionnary.
* xmlmemory.c: fixed a problem with the memory debug mutex
  release.
Daniel
2004-01-02 10:42:01 +00:00
William M. Brack
72ee48d55f Fixed memory leak reported by Dave Beckett Removed spurious comment
* parser.c, xmlmemory.c, include/libxml/xmlmemory.h: Fixed
  memory leak reported by Dave Beckett
* xmlschemas.c: Removed spurious comment reported on the mailing
  list
* xinclude.c, xpath.c, xpointer.c, libxml/include/xpointer.h:
  Further work on Bug 129967 concerning xpointer range handling
  and range-to function; much better, but still not complete
2003-12-30 08:30:19 +00:00
William M. Brack
0622fe8b03 enhanced by adding mutex to protect global structures in a multi-threading
* xmlmemory.c: enhanced by adding mutex to protect global
  structures in a multi-threading environment.  This fixed
  some random errors on the Threads regression tests.

* encoding.c, include/libxml/encoding.h: Enhanced the handling of
  UTF-16, UTF-16LE and UTF-16BE encodings.  Now UTF-16 output is
  handled internally by default, with proper BOM and UTF-16LE
  encoding.  Native UTF-16LE and UTF-16BE encoding will not generate
  BOM on output, and will be automatically recognized on input.
* test/utf16lebom.xml, test/utf16bebom.xml, result/utf16?ebom*:
  added regression tests for above.
2003-11-29 10:47:56 +00:00
Daniel Veillard
a9cce9cd0d Okay this is scary but it is just adding a configure option to disable
* HTMLtree.c SAX2.c c14n.c catalog.c configure.in debugXML.c
  encoding.c entities.c nanoftp.c nanohttp.c parser.c relaxng.c
  testAutomata.c testC14N.c testHTML.c testRegexp.c testRelax.c
  testSchemas.c testXPath.c threads.c tree.c valid.c xmlIO.c
  xmlcatalog.c xmllint.c xmlmemory.c xmlreader.c xmlschemas.c
  example/gjobread.c include/libxml/HTMLtree.h include/libxml/c14n.h
  include/libxml/catalog.h include/libxml/debugXML.h
  include/libxml/entities.h include/libxml/nanohttp.h
  include/libxml/relaxng.h include/libxml/tree.h
  include/libxml/valid.h include/libxml/xmlIO.h
  include/libxml/xmlschemas.h include/libxml/xmlversion.h.in
  include/libxml/xpathInternals.h python/libxml.c:
  Okay this is scary but it is just adding a configure option
  to disable output, this touches most of the files.
Daniel
2003-09-29 13:20:24 +00:00
Daniel Veillard
c064b476c8 better fix, avoids breaking the python bindings Daniel
* xmlmemory.c: better fix, avoids breaking the python bindings
Daniel
2003-09-29 10:55:05 +00:00
Daniel Veillard
fb43bd6fc9 fix a compilation problem when configuring with debug but without
* xmlmemory.c: fix a compilation problem when configuring
  with debug but without mem-debug
Daniel
2003-09-29 09:22:39 +00:00
Daniel Veillard
4432df239b cleanup, creating a new legacy.c module, made sure make tests ran in
* Makefile.am: cleanup, creating a new legacy.c module,
  made sure make tests ran in reduced conditions
* SAX.c SAX2.c configure.in entities.c globals.c parser.c
  parserInternals.c tree.c valid.c xlink.c xmlIO.c xmlcatalog.c
  xmlmemory.c xpath.c xmlmemory.c include/libxml/xmlversion.h.in:
  increased the modularization, allow to configure out
  validation code and legacy code, added a configuration
  option --with-minimum compiling only the mandatory code
  which then shrink to 200KB.
Daniel
2003-09-28 18:58:27 +00:00
William M. Brack
c193956ee1 small changes to syntax to get rid of compiler warnings. No changes to
* error.c HTMLparser.c testC14N.c testHTML.c testURI.c
  xmlcatalog.c xmlmemory.c xmlreader.c xmlschemastypes.c
  python/libxml.c include/libxml/xmlmemory.h: small changes
  to syntax to get rid of compiler warnings.  No changes
  to logic.
2003-08-05 15:52:22 +00:00
Daniel Veillard
a76fe5ca11 integrated the Out Of Memory test from Havoc Pennington #109368 a lot of
* Makefile.am testOOM.c testOOMlib.[ch] : integrated the Out Of
  Memory test from Havoc Pennington #109368
* SAX.c parser.c parserInternals.c tree.c uri.c valid.c
  xmlmemory.c xmlreader.c xmlregexp.c include/libxml/tree.h
  include/libxml/parser.h: a lot of memory allocation cleanups
  based on the results of the OOM testing
* check-relaxng-test-suite2.py: seems I forgot to commit the
  script.
Daniel
2003-04-24 16:06:47 +00:00
Daniel Veillard
3c908dca47 added xmlMallocAtomic() to be used when allocating blocks which do not
* DOCBparser.c HTMLparser.c c14n.c catalog.c encoding.c globals.c
  nanohttp.c parser.c parserInternals.c relaxng.c tree.c uri.c
  xmlmemory.c xmlreader.c xmlregexp.c xpath.c xpointer.c
  include/libxml/globals.h include/libxml/xmlmemory.h: added
  xmlMallocAtomic() to be used when allocating blocks which
  do not contains pointers, add xmlGcMemSetup() and xmlGcMemGet()
  to allow registering the full set of functions needed by
  a garbage collecting allocator like libgc, ref #109944
Daniel
2003-04-19 00:07:51 +00:00
Daniel Veillard
a9b66d00b5 new API building Python script, does the C parsing directly, generates a
* doc/apibuild.py doc/libxml2-api.xml doc/Makefile.am: new API
  building Python script, does the C parsing directly, generates
  a better API description including structure fieds defs and
  enums. Still a couple of bugs, but good enough for the python
  wrappers now.
* DOCBparser.c SAX.c nanohttp.c parser.c parserInternals.c tree.c
  valid.c xmlIO.c xmlmemory.c xmlreader.c xmlregexp.c xmlschemas.c
  include/libxml/schemasInternals.h include/libxml/tree.h: more
  cleanup based on the python analysis script reports.
* libxml.spec.in: make sure the API XML description is part of the
  devel package.
Daniel
2002-12-11 14:23:49 +00:00
Daniel Veillard
01c13b5be2 code cleanup, especially the function comments. fixed a small bug when
* DOCBparser.c HTMLparser.c c14n.c debugXML.c encoding.c hash.c
  nanoftp.c nanohttp.c parser.c parserInternals.c testC14N.c
  testDocbook.c threads.c tree.c valid.c xmlIO.c xmllint.c xmlmemory.c
  xmlreader.c xmlregexp.c xmlschemas.c xmlschemastypes.c xpath.c:
  code cleanup, especially the function comments.
* tree.c: fixed a small bug when freeing nodes which are XInclude ones.
Daniel
2002-12-10 15:19:08 +00:00
Daniel Veillard
d30be4add7 fixed configure for MPE/iX from Markus Henke fixed initialization problems
* configure.in: fixed configure for MPE/iX from Markus Henke
* xmlmemory.c: fixed initialization problems
* xpath.c: another set of patches from Richard Jinks this
  fixes "make XPathtests" on linux
Daniel
2002-03-28 18:25:31 +00:00
Daniel Veillard
34ce8bece2 preparing 2.4.18 updated and rebuilt the web site implement the new
* configure.in: preparing 2.4.18
* doc/*: updated and rebuilt the web site
* *.c libxml.h: implement the new IN_LIBXML scheme discussed with
  the Windows and Cygwin maintainers.
* parser.c: humm, changed the way the SAX parser work when
  xmlSubstituteEntitiesDefault(1) is set, it will then
  do the entity registration and loading by itself in case the
  user provided SAX getEntity() returns NULL.
* testSAX.c: added --noent to test the behaviour.
Daniel
2002-03-18 19:37:11 +00:00
Daniel Veillard
5997aca8b8 humm, changed the way the SAX parser work when
* parser.c: humm, changed the way the SAX parser work when
  xmlSubstituteEntitiesDefault(1) is set, it will then
  do the entity registration and loading by itself in case the
  user provided SAX getEntity() returns NULL.
* testSAX.c: added --noent to test the behaviour.
Daniel
2002-03-18 18:36:20 +00:00
Daniel Veillard
9f28f30a17 avoid a warning bug #71594 Daniel
* xmlmemory.c: avoid a warning bug #71594
Daniel
2002-02-15 20:48:08 +00:00