aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_eval.c
diff options
context:
space:
mode:
authorEliseo Martínez <eliseomarmol@gmail.com>2014-11-10 14:37:31 +0100
committerEliseo Martínez <eliseomarmol@gmail.com>2014-11-11 01:43:13 +0100
commit8bb2c2c0742c57150655e18cf8418a758cebdce8 (patch)
treedd4ac441804a027df2dac215daa19e70dad27fed /src/nvim/ex_eval.c
parent51080737df84c3ef4f8c17fb004c93b7d7a2850a (diff)
downloadrneovim-8bb2c2c0742c57150655e18cf8418a758cebdce8.tar.gz
rneovim-8bb2c2c0742c57150655e18cf8418a758cebdce8.tar.bz2
rneovim-8bb2c2c0742c57150655e18cf8418a758cebdce8.zip
Fix warnings: memory.c: xcalloc(): 0 size calloc: CW.
Problem : Undefined allocation of 0 bytes (CERT MEM04-C; CWE-131) @ 148. Diagnostic : Cautionary warning. Rationale : Reported circumstance (calling calloc with requesting 0 size allocation) can occur, and it's not an issue. It's perfectly legal doing so, though result is implementation dependant. A given implementation can return NULL or a valid pointer, so that free() can be called on it later the same as if it was a real pointer. Such a pointer should not be dereferenced, though. Now, for some reason I can't explain, compiler is warning us in the case of calloc, but not in the case of malloc, which is doing the same. Resolution : Refactor memory functions to avoid using implementation dependant behaviour. Proposed code is neater to read, and it avoids calling system memory functions with size 0, thus behaving the same everywhere. Note that semantics for xmalloc/xcalloc is slightly changed: - Previously, an implementation that returns a valid pointer on malloc/calloc with 0 size, would return that pointer to xmalloc/xcalloc caller. - Currently, a regular pointer is always returned.
Diffstat (limited to 'src/nvim/ex_eval.c')
0 files changed, 0 insertions, 0 deletions