# HG changeset patch # User Evan Schoenberg # Date 1178389789 0 # Node ID 11a0f2b4ac83b82616eb34b60bde712dc6cbb004 # Parent f9e7a7dacda3ff028c1581e7c7faeb0ee13c3e45 If the read() in resolved() fails, we should detect the failure and set size (which it would otherwise set, since it is passed by reference) to 0 and res to NULL. This ''may'' fix a rather odd crash described in Adium Trac #6623 (http://trac.adiumx.com/ticket/6623), and it is certainly good sanity checking. diff -r f9e7a7dacda3 -r 11a0f2b4ac83 libpurple/dnssrv.c --- a/libpurple/dnssrv.c Sat May 05 18:14:48 2007 +0000 +++ b/libpurple/dnssrv.c Sat May 05 18:29:49 2007 +0000 @@ -192,11 +192,19 @@ PurpleSrvCallback cb = query_data->cb; int status; - read(source, &size, sizeof(int)); - purple_debug_info("dnssrv","found %d SRV entries\n", size); - tmp = res = g_new0(PurpleSrvResponse, size); - for (i = 0; i < size; i++) { - read(source, tmp++, sizeof(PurpleSrvResponse)); + if (read(source, &size, sizeof(int)) > 0) + { + purple_debug_info("dnssrv","found %d SRV entries\n", size); + tmp = res = g_new0(PurpleSrvResponse, size); + for (i = 0; i < size; i++) { + read(source, tmp++, sizeof(PurpleSrvResponse)); + } + } + else + { + purple_debug_info("dnssrv","found 0 SRV entries; errno is %i\n", errno); + size = 0; + res = NULL; } cb(res, size, query_data->extradata);