A bug like that is usually indicative of a buffer overrun.
int rgb[3]; rgb[4] = 7;
Or of cavalier casting. short hue; int* p = (int*)&hue; *p = 0;
Without seeing the code (or some sample code that replicates the bug), it would be difficult to guess less likely scenarios.
HTH, --Eljay