Fixed dead pointer problem when handling interfaces
[lcr.git] / interface.c
index 89aa582..ca569be 100644 (file)
@@ -1699,11 +1699,7 @@ void do_screen(int out, char *id, int idsize, int *type, int *present, const cha
        char suffix[64];
        struct interface *interface = interface_first;
 
-       while (interface) {
-               if (!strcmp(interface->name, interface_name))
-                       break;
-               interface = interface->next;
-       }
+       interface = getinterfacebyname(interface_name);
        if (!interface)
                return;
 
@@ -1830,3 +1826,16 @@ void do_screen(int out, char *id, int idsize, int *type, int *present, const cha
        }
 }
 
+struct interface *getinterfacebyname(const char *name)
+{
+       struct interface *interface = interface_first;
+
+       while (interface) {
+               if (!strcmp(interface->name, name))
+                       return interface;
+               interface = interface->next;
+       }
+
+       return NULL;
+}
+