Mercurial > cpython-lru_cache-weakref
diff Modules/socketmodule.c @ 39502:799bcf0ccbfd legacy-trunk
Patch #1511317: don't crash on invalid hostname info
| author | Georg Brandl <georg@python.org> |
|---|---|
| date | Mon, 14 Aug 2006 22:10:24 +0000 |
| parents | 85fdcdfca85c |
| children | c43787e6d706 |
line wrap: on
line diff
--- a/Modules/socketmodule.c Mon Aug 14 22:01:24 2006 +0000 +++ b/Modules/socketmodule.c Mon Aug 14 22:10:24 2006 +0000 @@ -3041,17 +3041,20 @@ if ((addr_list = PyList_New(0)) == NULL) goto err; - for (pch = h->h_aliases; *pch != NULL; pch++) { - int status; - tmp = PyString_FromString(*pch); - if (tmp == NULL) - goto err; - - status = PyList_Append(name_list, tmp); - Py_DECREF(tmp); - - if (status) - goto err; + /* SF #1511317: h_aliases can be NULL */ + if (h->h_aliases) { + for (pch = h->h_aliases; *pch != NULL; pch++) { + int status; + tmp = PyString_FromString(*pch); + if (tmp == NULL) + goto err; + + status = PyList_Append(name_list, tmp); + Py_DECREF(tmp); + + if (status) + goto err; + } } for (pch = h->h_addr_list; *pch != NULL; pch++) {
