net_gethostbyname_nonblock(): don't crash if net_gethosterror() returns

error message as NULL.

Initialize winsock with win32.


git-svn-id: http://svn.irssi.org/repos/irssi/trunk@966 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2000-12-05 19:43:12 +00:00 committed by cras
commit 346808789c
2 changed files with 20 additions and 3 deletions

View file

@ -103,11 +103,11 @@ int net_gethostbyname_nonblock(const char *addr, GIOChannel *pipe)
errorstr = NULL;
} else {
errorstr = net_gethosterror(rec.error);
rec.errlen = strlen(errorstr)+1;
rec.errlen = errorstr == NULL ? 0 : strlen(errorstr)+1;
}
g_io_channel_write_block(pipe, &rec, sizeof(rec));
if (rec.error != 0)
if (rec.errlen != 0)
g_io_channel_write_block(pipe, (void *) errorstr, rec.errlen);
#ifndef WIN32