summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJakub Jelen <jjelen@redhat.com>2019-03-28 15:17:15 +0100
committerJakub Jelen <jjelen@redhat.com>2019-07-04 15:01:59 +0200
commitf9834bff1ea970e876a38a23e31cfa28ff881984 (patch)
tree63f8ba9fefdcfe6b2e475a81138d3defc16db038 /src
parent9c14062f615040a444eb153edc481b80fff2cdae (diff)
simpletlv: Do not allocate if there is no way to return the allocated data
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/simpletlv.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/simpletlv.c b/src/simpletlv.c
index 9332fb5..66aa5c3 100644
--- a/src/simpletlv.c
+++ b/src/simpletlv.c
@@ -85,12 +85,12 @@ simpletlv_encode_internal(struct simpletlv_member *tlv, size_t tlv_len,
if (expect_len <= 0)
return expect_len;
- if (outlen == 0) {
+ if (outlen == 0 && out != NULL) {
/* allocate a new buffer */
a = g_malloc(expect_len);
tmp = a;
tmp_len = expect_len;
- } else if ((int)outlen >= expect_len) {
+ } else if ((int)outlen >= expect_len && out != NULL) {
tmp = *out;
tmp_len = outlen;
} else {