@@ -112,7 +112,7 @@ int range_format(lua_State *L) {
112112 auto startLine = lua_tointeger (L, 3 );
113113 auto endLine = lua_tointeger (L, 4 );
114114
115- if (startLine < 0 || endLine < 0 ){
115+ if (startLine < 0 || endLine < 0 ) {
116116 lua_pushboolean (L, false );
117117 lua_pushstring (L, " start line or end line < 0" );
118118 return 2 ;
@@ -170,8 +170,14 @@ int type_format(lua_State *L) {
170170 try {
171171 std::string filename = lua_tostring (L, 1 );
172172 std::string text = lua_tostring (L, 2 );
173- int line = lua_tointeger (L, 3 );
174- int character = lua_tointeger (L, 4 );
173+ auto line = lua_tointeger (L, 3 );
174+ auto character = lua_tointeger (L, 4 );
175+
176+ if (line < 0 || character < 0 ){
177+ lua_pushboolean (L, false );
178+ lua_pushstring (L, " line or character param error" );
179+ return 2 ;
180+ }
175181
176182 LuaCodeFormat::ConfigMap configMap;
177183
@@ -204,7 +210,8 @@ int type_format(lua_State *L) {
204210 }
205211 }
206212 auto typeFormatResult = LuaCodeFormat::GetInstance ()
207- .TypeFormat (filename, line, character,
213+ .TypeFormat (filename,
214+ static_cast <std::size_t >(line), static_cast <std::size_t >(character),
208215 std::move (text), configMap, stringTypeOptions);
209216
210217 if (typeFormatResult.empty ()) {
0 commit comments