Social Reiot

Social Game Developer wandering in strange dungeon.

Inet_ntoa 의 위험성

아래와 같이 내부 버퍼를 리턴하는 함수를 연속적으로 사용할 경우에는 주의해야 한다. 그냥 string 으로 감싸서 사용하는 것이 정신건강에 좋다. (단 타이핑 횟수는 .c_str() 때문에 꽤 증가한다)

printf( “external_address=%s internal_address=%s”, inet_ntoa(exaddr), inet_ntoa(inaddr));

Comments