fix heap corruption in carbon plugin

read and write using an out of bounds index