You are missing a `free(matches);` here