summaryrefslogtreecommitdiff
path: root/src/cac.c
diff options
context:
space:
mode:
authorJakub Jelen <jjelen@redhat.com>2019-03-28 15:01:23 +0100
committerJakub Jelen <jjelen@redhat.com>2019-07-04 15:01:48 +0200
commit0f9cab8c3d96059bfeedebc4a92f62f50b236372 (patch)
treed605ec7213483a78e7771a8d332a05a4e1bae35d /src/cac.c
parent1d4fdfb73440932c3349bdde1d62f03a5b864ca6 (diff)
cac: Avoid pointers from static structure to the function-local variables after return
clang error: libcacard-2.5.2/src/cac.c:2021:1: warning: Address of stack memory associated with local variable 'number_objects' is still referred to by the global variable 'properties' upon returning to the caller. This will be a dangling reference Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Diffstat (limited to 'src/cac.c')
-rw-r--r--src/cac.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/cac.c b/src/cac.c
index 2c96c4a..687a828 100644
--- a/src/cac.c
+++ b/src/cac.c
@@ -1992,6 +1992,11 @@ cac_new_empty_applet_private(unsigned char objects[][2], unsigned int objects_le
applet_private->properties_len = properties_len;
applet_private->long_properties_len = properties_len; /*TODO*/
applet_private->properties = simpletlv_clone(properties, properties_len);
+
+ /* Avoid dangling pointers in the static structure */
+ properties[0].value.value = NULL;
+ properties[1].value.value = NULL;
+
if (applet_private->properties == NULL)
goto failure;