library: fixed a bug where the flashlight could be unresponsive due to variable overflow