@@ -55,7 +55,7 @@ int context_is_valid(const policydb_t * p, const context_struct_t * c)
* Role must be authorized for the type.
*/
role = p->role_val_to_struct[c->role - 1];
- if (!ebitmap_get_bit(&role->cache, c->type - 1))
+ if (!role || !ebitmap_get_bit(&role->cache, c->type - 1))
/* role may not be associated with type */
return 0;
@@ -1068,7 +1068,7 @@ int policydb_index_others(sepol_handle_t * handle,
free(p->role_val_to_struct);
p->role_val_to_struct = (role_datum_t **)
- malloc(p->p_roles.nprim * sizeof(role_datum_t *));
+ calloc(p->p_roles.nprim, sizeof(role_datum_t *));
if (!p->role_val_to_struct)
return -1;