+2017-09-10 Sergio Durigan Junior <sergiodj@redhat.com>
+
+ * regcache.c (get_thread_regcache): Guard calls to "memset"
+ with "!VEC_empty".
+
2017-09-10 Sergio Durigan Junior <sergiodj@redhat.com>
* linux-low.c (handle_extended_wait): Use
current_thread = thread;
/* Invalidate all registers, to prevent stale left-overs. */
- memset (regcache->register_status, REG_UNAVAILABLE,
- VEC_length (tdesc_reg_p, regcache->tdesc->reg_defs));
+ if (!VEC_empty (tdesc_reg_p, regcache->tdesc->reg_defs))
+ memset (regcache->register_status, REG_UNAVAILABLE,
+ VEC_length (tdesc_reg_p, regcache->tdesc->reg_defs));
fetch_inferior_registers (regcache, -1);
current_thread = saved_thread;
regcache->registers_valid = 1;
regcache->registers_owned = 1;
regcache->register_status
= (unsigned char *) xmalloc (VEC_length (tdesc_reg_p, tdesc->reg_defs));
- memset ((void *) regcache->register_status, REG_UNAVAILABLE,
- VEC_length (tdesc_reg_p, tdesc->reg_defs));
+ if (!VEC_empty (tdesc_reg_p, tdesc->reg_defs))
+ memset ((void *) regcache->register_status, REG_UNAVAILABLE,
+ VEC_length (tdesc_reg_p, tdesc->reg_defs));
#else
gdb_assert_not_reached ("can't allocate memory from the heap");
#endif