*** libspf2-1.2.5/src/libspf2/spf_dns_resolv.c Sat Feb 19 03:38:12 2005 --- libspf2-1.2.5/src/libspf2/spf_dns_resolv.c Wed Jun 20 15:15:26 2007 *************** *** 144,151 **** --- 144,163 ---- if (res_spec == NULL) { res_state = (struct __res_state *) malloc(sizeof(struct __res_state)); + if (res_state == NULL) { + SPF_error("Failed to aquire res_state memory"); + return NULL; + } + /* Always initialize to zero, some resolver libary may + * try to expect an old state which will then used + * to cleanup from this previous state - if this is garbage + * the resolver library could raise a fault after some time ... + */ + memset((void *)res_state, 0, sizeof(struct __res_state)); + if (res_ninit(res_state) != 0) { SPF_error("Failed to call res_ninit()"); + return NULL; } pthread_setspecific(res_state_key, (void *)res_state); }