Improve error code when getting map items by label
Not-well-formed errors were being masked as not-found errors for functions like QCBORDecode_GetInt64InMapN .. for all the "InMap" functions.
diff --git a/src/qcbor_decode.c b/src/qcbor_decode.c
index d1be74d..4d31b69 100644
--- a/src/qcbor_decode.c
+++ b/src/qcbor_decode.c
@@ -2951,14 +2951,14 @@
uReturn = QCBOR_ERR_DUPLICATE_LABEL;
goto Done;
}
- /* Also try to match its type */
- if(!MatchType(Item, pItemArray[nIndex])) {
- uReturn = QCBOR_ERR_UNEXPECTED_TYPE;
+ if(uResult != QCBOR_SUCCESS) {
+ /* The label matches, but the data item is in error */
+ uReturn = uResult;
goto Done;
}
-
- if(uResult != QCBOR_SUCCESS) {
- uReturn = uResult;
+ if(!MatchType(Item, pItemArray[nIndex])) {
+ /* The data item is not of the type(s) requested */
+ uReturn = QCBOR_ERR_UNEXPECTED_TYPE;
goto Done;
}