summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorThomas Jarosch <tomj@simonv.com>2014-12-27 17:33:24 +0100
committerThomas Jarosch <tomj@simonv.com>2014-12-27 17:33:24 +0100
commite7c282fed754bfc4a2fbdc2e8e1a7598b5fae27c (patch)
treeb8b6f8d64597e75d5fd25a71734b2588748fec91 /lib
parentd68262eede9c5a5f911f9619784f466a6730e21a (diff)
More standard conforming codec_realloc()
- Leave original ptr untouched if allocation fails (bail out early) - Behave like malloc() in case ptr is NULL Change-Id: Ib854ca19bd0e069999b7780d2d9a533ece705add
Diffstat (limited to 'lib')
-rw-r--r--lib/rbcodec/codecs/lib/codeclib.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/rbcodec/codecs/lib/codeclib.c b/lib/rbcodec/codecs/lib/codeclib.c
index a12038eeb8..1f52c00434 100644
--- a/lib/rbcodec/codecs/lib/codeclib.c
+++ b/lib/rbcodec/codecs/lib/codeclib.c
@@ -91,8 +91,12 @@ void* codec_realloc(void* ptr, size_t size)
{
void* x;
x = codec_malloc(size);
- ci->memcpy(x, ptr, size);
- codec_free(ptr);
+ if (x == NULL)
+ return NULL;
+ if (ptr) {
+ ci->memcpy(x, ptr, size);
+ codec_free(ptr);
+ }
return(x);
}