hello everyone!
I recently read the ORBit-0.5.3 source
code, I wonder if there is a memory problem in file connection.c line 448. Since
the "g_strdup" malloc'd a heap memory, while "inet_ntoa" just return a static
memory. And I trace the program with gdb, I found the memory alloc'd by g_strdup
never freed!
Can anyone answer me? thanks
:)
Here is the Code:
436 switch(parent->icnxtype)
{
437 case IIOP_IPV4: 438 n = sizeof(struct sockaddr_in); 439 if(getpeername(GIOP_CONNECTION_GET_FD(fd_cnx), (struct sockaddr *)&fd_cnx- >u.ipv4.location, &n)) 440 { 441 fd_cnx->u.ipv4.hostname = g_strdup(""); 442 } 443 else 444 { 445 hent = gethostbyaddr((const char *)&fd_cnx->u.ipv4.location.sin_addr.s _addr, 4, AF_INET); 446 if(hent) 447 { 448 fd_cnx->u.ipv4.hostname = g_strdup(hent->h_name); 449 } 450 else 451 { 452 fd_cnx->u.ipv4.hostname = inet_ntoa(*((struct in_addr *)&fd_cnx->u .ipv4.location.sin_addr)); 453 } 454 } 455 break; |