gethostbyaddr segmentation error FAQ

p, li { white-space: pre-wrap; }

struct hostent* hostEnt;

hostEnt=gethostbyaddr(inet_ntoa(ptr->ip_src),sizeof(ptr->ip_src),AF_INET);

if(!hostEnt)

{

tmp=new QStandardItem("No Name");

Row.append(tmp);

}else

{

tmp=new QStandardItem(hostEnt->h_name);

Row.append(tmp);

}

above is right,but before I get to know this issue, I didn't check the hostEnt's value,so when there is no result to return , hostEnt-> operation will throw out segmentation error

 

 

note that....

你可能感兴趣的:(gethostbyaddr segmentation error FAQ)