validate the arguments to avoid crash
fix a bug with select size
add return value for load char