]> git.eshelyaron.com Git - emacs.git/commit
Memory-management cleanup in make-docfile
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 10 Feb 2016 18:14:50 +0000 (10:14 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 10 Feb 2016 19:41:10 +0000 (11:41 -0800)
commit25ec995c064d4e658fe3f9af084f120ae21a021a
tree796426490202643af30b6108c8968d311e22f7a9
parent02d925e9e55089fabfe03e5a911c391b9322978f
Memory-management cleanup in make-docfile

I compiled it with -fsanitize=address and fixed the leaks it detected.
Also, I changed it to prefer signed to unsigned integer types,
and to check for integer overflow.
* lib-src/make-docfile.c:
Include <stddef.h>, <stdint.h>, <intprops.h>, <min-max.h>.
(memory_exhausted): New function.
(xmalloc, xrealloc): Use it.
(xmalloc, xrealloc, scan_file, struct rcsoc_state, write_c_args)
(uncompiled, scan_lisp_file):
Prefer signed integer types to unsigned.
(xstrdup): Remove.  All uses removed.
(num_globals, num_globals_allocated, write_globals, scan_c_stream):
Use ptrdiff_t, not int, for indexes that in theory could exceed INT_MAX.
(add_global): Use const to pacify --enable-gcc-warnings.
Make a copy here, rather than relying on strdup calls later.
(add_global, write_globals, scan_c_stream):
Avoid integer overflow when calculating sizes.
(write_globals, scan_c_stream, scan_lisp_file): Avoid memory leak.
(scan_c_stream): Check for add_global failure.
lib-src/make-docfile.c