Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/cborparser_dup_string.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@

#include "cbor.h"
#include "compilersupport_p.h"
#include <stdlib.h>

#if defined(CBOR_CUSTOM_ALLOC_INCLUDE)
# include CBOR_CUSTOM_ALLOC_INCLUDE
#else
# include <stdlib.h>
# define cbor_malloc malloc
# define cbor_free free
#endif

/**
* \fn CborError cbor_value_dup_text_string(const CborValue *value, char **buffer, size_t *buflen, CborValue *next)
Expand Down Expand Up @@ -105,14 +112,14 @@ CborError _cbor_value_dup_string(const CborValue *value, void **buffer, size_t *
return err;

++*buflen;
*buffer = malloc(*buflen);
*buffer = cbor_malloc(*buflen);
if (!*buffer) {
/* out of memory */
return CborErrorOutOfMemory;
}
err = _cbor_value_copy_string(value, *buffer, buflen, next);
if (err) {
free(*buffer);
cbor_free(*buffer);
return err;
}
return CborNoError;
Expand Down