David Bateman wrote:
> Michael Goffioul wrote:
>   
>> On Thu, May 15, 2008 at 1:38 PM, Thomas Weber
>> <[EMAIL PROTECTED]> wrote:
>>   
>>     
>>> Octave 3.0.1, sockets 1.0.4:
>>>
>>>  octave:4> gethostbyname("tw-math.de")
>>>  ans = 83.151.21.166
>>>  octave:5> gethostbyname
>>>  panic: Segmentation fault -- stopping myself...
>>>  attempting to save variables to `octave-core'...
>>>  save to `octave-core' complete
>>>  Segmentation fault
>>>
>>>
>>>  I agree the function needs an argument, but I would appreciate if the
>>>  interpreter didn't crash ;)
>>>     
>>>       
>> I also received a bug report concerning the sockets package that
>> makes octave to crash when functions are called with wrong
>> arguments (IIRC, it was with "listen").
>>
>>   
>>     
>
> Does the attached patch help?
>
> D.
>
>
>   
Sorry, use the attached version instead

D.

-- 
David Bateman                                [EMAIL PROTECTED]
Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph) 
Parc Les Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob) 
91193 Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax) 

The information contained in this communication has been classified as: 

[x] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary

Index: main/sockets/src/sockets.cc
===================================================================
--- main/sockets/src/sockets.cc (revision 5044)
+++ main/sockets/src/sockets.cc (working copy)
@@ -456,25 +456,31 @@
 DEFUN_DLD(gethostbyname,args,nargout, \
          "gethostbyname(string)\nSee the gethostbyname() man pages")
 {
+  int nargin = args.length ();
   struct hostent*    hostInfo = NULL;
-  string_vector host_list;
+  octave_value retval;
 
-
-  if ( args(0).is_string() )
-  {
-    string addr = args(0).string_value();
-    hostInfo = gethostbyname( addr.c_str() );
-    if ( hostInfo )
+  if (nargin != 1)
+    print_usage ();
+  else if ( args(0).is_string() )
     {
-      for ( int i = 0 ; i < hostInfo->h_length/4 ; i++ )
-      {
-       string temp_addr = string(  inet_ntoa( *(struct 
in_addr*)hostInfo->h_addr_list[i] ));
-       host_list.append( temp_addr );
-      }
+      string_vector host_list;
+      string addr = args(0).string_value();
+      hostInfo = gethostbyname( addr.c_str() );
+      if ( hostInfo )
+       {
+         for ( int i = 0 ; i < hostInfo->h_length/4 ; i++ )
+           {
+             string temp_addr = string(  inet_ntoa( *(struct 
in_addr*)hostInfo->h_addr_list[i] ));
+             host_list.append( temp_addr );
+           }
+       }
+      retval = octave_value (host_list);
     }
-  }
+  else
+    print_usage ();
 
-  return octave_value(host_list);
+  return retval;
 }
 
 // PKG_ADD: autoload ("send", "sockets.oct");
@@ -675,7 +681,8 @@
   int backlog = args(1).int_value();
 //  octave_stdout << "BACKLOG: " << backlog << endl;
 
-  retval = ::listen( s->get_sock_fd(), backlog );
+  if (! error_state)
+    retval = ::listen( s->get_sock_fd(), backlog );
 
   return octave_value(retval);
 }
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft 
Defy all challenges. Microsoft(R) Visual Studio 2008. 
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Octave-dev mailing list
Octave-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/octave-dev

Reply via email to