Commit b2a1a485 authored by David Vincze's avatar David Vincze Committed by Andrzej Puzdrowski
Browse files

imgtool: Fix 'custom_tlvs' argument handling

When Image.create() is called without the 'custom_tlvs' argument, it
gets its default value (None). It must be checked before performing
any operations on/with it.

Change-Id: I8e0755265f35f9eeb796fe078a6ad8c8d9f2b8da
Signed-off-by: default avatarDavid Vincze <david.vincze@linaro.org>
parent 67e3fff0
Loading
Loading
Loading
Loading
+3 −2
Changes for scripts/imgtool/image.py: 3 added lines, 2 removed lines.
Original line number Diff line number Diff line
# Copyright 2018 Nordic Semiconductor ASA
# Copyright 2017 Linaro Limited
# Copyright 2017-2020 Linaro Limited
# Copyright 2019-2020 Arm Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -327,7 +327,7 @@ class Image():
            dependencies_num = len(dependencies[DEP_IMAGES_KEY])
            protected_tlv_size += (dependencies_num * 16)

        if custom_tlvs:
        if custom_tlvs is not None:
            for value in custom_tlvs.values():
                protected_tlv_size += TLV_SIZE + len(value)

@@ -375,6 +375,7 @@ class Image():
                                    )
                    prot_tlv.add('DEPENDENCY', payload)

            if custom_tlvs is not None:
                for tag, value in custom_tlvs.items():
                    prot_tlv.add(tag, value)