[vlc-commits] x*alloc: handle zero-size allocations (fixes #19052)
Rémi Denis-Courmont
git at videolan.org
Wed Nov 8 18:03:22 CET 2017
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Nov 8 19:02:50 2017 +0200| [6b386c16fd6cab124ba2f07ea1fc438df331bc52] | committer: Rémi Denis-Courmont
x*alloc: handle zero-size allocations (fixes #19052)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6b386c16fd6cab124ba2f07ea1fc438df331bc52
---
include/vlc_common.h | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/include/vlc_common.h b/include/vlc_common.h
index 199404d164..662248ceb3 100644
--- a/include/vlc_common.h
+++ b/include/vlc_common.h
@@ -863,26 +863,26 @@ static inline const char *vlc_pgettext_aux( const char *ctx, const char *id )
/*****************************************************************************
* Loosy memory allocation functions. Do not use in new code.
*****************************************************************************/
-static inline void *xmalloc (size_t len)
+static inline void *xmalloc(size_t len)
{
- void *ptr = malloc (len);
- if (unlikely (ptr == NULL))
- abort ();
+ void *ptr = malloc(len);
+ if (unlikely(ptr == NULL && len > 0))
+ abort();
return ptr;
}
-static inline void *xrealloc (void *ptr, size_t len)
+static inline void *xrealloc(void *ptr, size_t len)
{
- void *nptr = realloc (ptr, len);
- if (unlikely (nptr == NULL))
- abort ();
+ void *nptr = realloc(ptr, len);
+ if (unlikely(nptr == NULL && len > 0))
+ abort();
return nptr;
}
-static inline void *xcalloc (size_t n, size_t size)
+static inline void *xcalloc(size_t n, size_t size)
{
- void *ptr = calloc (n, size);
- if (unlikely (ptr == NULL))
+ void *ptr = calloc(n, size);
+ if (unlikely(ptr == NULL && (n > 0 || size > 0)))
abort ();
return ptr;
}
More information about the vlc-commits
mailing list