aboutsummaryrefslogtreecommitdiff
path: root/src/inet.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/inet.c')
-rw-r--r--src/inet.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/inet.c b/src/inet.c
index d713643..d102060 100644
--- a/src/inet.c
+++ b/src/inet.c
@@ -172,21 +172,25 @@ static void inet_pushresolved(lua_State *L, struct hostent *hp)
172 i = 1; 172 i = 1;
173 alias = hp->h_aliases; 173 alias = hp->h_aliases;
174 lua_newtable(L); 174 lua_newtable(L);
175 while (*alias) { 175 if (alias) {
176 lua_pushnumber(L, i); 176 while (*alias) {
177 lua_pushstring(L, *alias); 177 lua_pushnumber(L, i);
178 lua_settable(L, -3); 178 lua_pushstring(L, *alias);
179 i++; alias++; 179 lua_settable(L, -3);
180 i++; alias++;
181 }
180 } 182 }
181 lua_settable(L, resolved); 183 lua_settable(L, resolved);
182 i = 1; 184 i = 1;
183 lua_newtable(L); 185 lua_newtable(L);
184 addr = (struct in_addr **) hp->h_addr_list; 186 addr = (struct in_addr **) hp->h_addr_list;
185 while (*addr) { 187 if (addr) {
186 lua_pushnumber(L, i); 188 while (*addr) {
187 lua_pushstring(L, inet_ntoa(**addr)); 189 lua_pushnumber(L, i);
188 lua_settable(L, -3); 190 lua_pushstring(L, inet_ntoa(**addr));
189 i++; addr++; 191 lua_settable(L, -3);
192 i++; addr++;
193 }
190 } 194 }
191 lua_settable(L, resolved); 195 lua_settable(L, resolved);
192} 196}