You're lucky that worked in the first place. You forgot to assign memory to slab_ents, so in your first loop you're overwriting memory. In your second loop you then free random memory area as the data at that memory address could point anywhere in the meantime.


Always learn from history, to be sure you make the same mistakes again...