Error reporting for GetNthTag functions
diff --git a/src/qcbor_decode.c b/src/qcbor_decode.c
index 3e36e5a..001a778 100644
--- a/src/qcbor_decode.c
+++ b/src/qcbor_decode.c
@@ -2193,6 +2193,9 @@
                                const QCBORItem    *pItem,
                                uint32_t            uIndex)
 {
+   if(pItem->uDataType == QCBOR_TYPE_NONE) {
+      return CBOR_TAG_INVALID64;
+   }
    if(uIndex >= QCBOR_MAX_TAGS_PER_ITEM) {
       return CBOR_TAG_INVALID64;
    } else {
@@ -2206,6 +2209,9 @@
 uint64_t QCBORDecode_GetNthTagOfLast(const QCBORDecodeContext *pMe,
                                      uint32_t                  uIndex)
 {
+   if(pMe->uLastError != QCBOR_SUCCESS) {
+      return CBOR_TAG_INVALID64;
+   }
    if(uIndex >= QCBOR_MAX_TAGS_PER_ITEM) {
       return CBOR_TAG_INVALID64;
    } else {