Browse Source

core: socket info - relocate check for index to get more debugging details

(cherry picked from commit b7dcbc37aceaefecf9a0f7367526a331d42269ea)
Daniel-Constantin Mierla 11 months ago
parent
commit
f3d510f6f1
1 changed files with 8 additions and 6 deletions
  1. 8 6
      src/core/socket_info.c

+ 8 - 6
src/core/socket_info.c

@@ -1532,12 +1532,6 @@ static int build_iface_list(void)
 			rtl = IFA_PAYLOAD(nlp);
 
 			index = ifi->ifa_index;
-			num++;
-			if(index >= MAX_IFACE_NO) {
-				LM_ERR("Invalid interface index returned: %d (n: %d) - skip\n",
-						index, num);
-				continue;
-			}
 
 			entry = (struct idx *)pkg_malloc(sizeof(struct idx));
 			if(entry == 0) {
@@ -1604,6 +1598,14 @@ static int build_iface_list(void)
 				}
 			}
 
+			if(index >= MAX_IFACE_NO) {
+				LM_ERR("Invalid interface index returned: %d (n: %d) - skip\n",
+						index, num);
+				pkg_free(entry);
+				continue;
+			}
+			num++;
+
 			if(strlen(ifaces[index].name) == 0 && strlen(name) > 0) {
 				memcpy(ifaces[index].name, name, MAX_IF_LEN - 1);
 				ifaces[index].name[MAX_IF_LEN - 1] = '\0';