Resolve pointers in capn_getv*

Reported by @xvuko, fixes #20
This commit is contained in:
David Lamparter 2017-05-19 09:05:47 +02:00
parent 7c819065e0
commit e0d1c36e43
2 changed files with 6 additions and 2 deletions

View file

@ -41,7 +41,9 @@ UINT_T CAT(capn_get,SZ) (LIST_T l, int off) {
int CAT(capn_getv,SZ) (LIST_T l, int off, UINT_T *to, int sz) {
int i;
capn_ptr p = l.p;
capn_ptr p;
capn_resolve(&l.p);
p = l.p;
if (off + sz > p.len) {
sz = p.len - off;
}

View file

@ -898,7 +898,9 @@ int capn_set1(capn_list1 l, int off, int val) {
int capn_getv1(capn_list1 l, int off, uint8_t *data, int sz) {
/* Note we only support aligned reads */
int bsz;
capn_ptr p = l.p;
capn_ptr p;
capn_resolve(&l.p);
p = l.p;
if (p.type != CAPN_BIT_LIST || (off & 7) != 0)
return -1;