diff options
author | Thomas White <taw@physics.org> | 2021-05-07 14:56:54 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2021-05-07 14:56:54 +0200 |
commit | 05dacf8af84b6f2e962535e21de09b68693bffeb (patch) | |
tree | 52908eef206e090599816353e02ded72c532091e /libcrystfel/src | |
parent | 7052eda1975dba37781d64d7e2d2b916e300ccdb (diff) |
MsgPack: Use the right pointer for "bin" keys
Diffstat (limited to 'libcrystfel/src')
-rw-r--r-- | libcrystfel/src/image-msgpack.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/libcrystfel/src/image-msgpack.c b/libcrystfel/src/image-msgpack.c index 3465cc71..827b7724 100644 --- a/libcrystfel/src/image-msgpack.c +++ b/libcrystfel/src/image-msgpack.c @@ -77,14 +77,28 @@ static msgpack_object *find_msgpack_kv(msgpack_object *obj, const char *key) if ( obj->type != MSGPACK_OBJECT_MAP ) return NULL; for ( i=0; i<obj->via.map.size; i++ ) { - const char *kstr; - size_t klen; - if ( (obj->via.map.ptr[i].key.type != MSGPACK_OBJECT_STR) - && (obj->via.map.ptr[i].key.type != MSGPACK_OBJECT_BIN) ) continue; - kstr = obj->via.map.ptr[i].key.via.str.ptr; - klen = obj->via.map.ptr[i].key.via.str.size; - if ( strncmp(kstr, key, klen) == 0 ) { - return &obj->via.map.ptr[i].val; + + if ( obj->via.map.ptr[i].key.type == MSGPACK_OBJECT_STR ) { + + const char *kstr; + size_t klen; + + kstr = obj->via.map.ptr[i].key.via.str.ptr; + klen = obj->via.map.ptr[i].key.via.str.size; + if ( strncmp(kstr, key, klen) == 0 ) { + return &obj->via.map.ptr[i].val; + } + + } else if ( obj->via.map.ptr[i].key.type == MSGPACK_OBJECT_BIN ) { + + const char *kstr; + size_t klen; + + kstr = obj->via.map.ptr[i].key.via.bin.ptr; + klen = obj->via.map.ptr[i].key.via.bin.size; + if ( strncmp(kstr, key, klen) == 0 ) { + return &obj->via.map.ptr[i].val; + } } } return NULL; |