fix strtol return code handling bug