jmap: fix aliasing issues, one real testcase bug
[ccan] / ccan / jmap / jmap_type.h
index dbbb97bf28d3cc0109ebd8eb17ff37b4431dc43c..e61ba10946d260083c96207217b4d61eda2f2179 100644 (file)
@@ -264,8 +264,11 @@ static inline void jmap_##name##_putval(struct jmap_##name *map,   \
 static inline type **jmap_##name##_firstval(const struct jmap_##name *map, \
                                            itype **index)              \
 {                                                                      \
-       return (type **)jmap_firstval((const struct jmap *)map,         \
-                                     (size_t *)index);                 \
+       size_t idx;                                                     \
+       type **ret;                                                     \
+       ret = (type **)jmap_firstval((const struct jmap *)map, &idx);   \
+       *index = (void *)idx;                                           \
+       return ret;                                                     \
 }                                                                      \
 static inline type **jmap_##name##_nextval(const struct jmap_##name *map, \
                                           itype **index)               \