Prevent crash/assert on access to "uninitialized" device.if_info.name.

While this is one possible way to fix it, it probably is not the "right"
way to do it. I just don't know which one would be right. I regard
several options to be cleaner:
- Remove if_info from interface_t altogether and add the required fields
  to interface_t directly.
- Never use device.if_info.name but always use device.name (same with
  friendly_name)
- Initialize both fields the same (same with friendly_name)
- Also not nice: device is optically a struct, not a pointer. So into the
  function, when we create a new struct (that's where the error "is made"),
  the same name continues to be used.

Not improving my confidence into my solution:
- I haven't bee able to figure out why the automated Windows builds don't
  crash/assert.

Last but not least: The two qt/gtk functions should probably have their common
core extracted into a common function.

Change-Id: I1b36d1765d1a1ec975927cb5785a1540ba4952f5
Ping-Bug: 13448
Reviewed-on: https://code.wireshark.org/review/20721
Petri-Dish: Jörg Mayer <jmayer@loplof.de>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Jörg Mayer <jmayer@loplof.de>
This commit is contained in:
Joerg Mayer 2017-03-26 19:11:02 +02:00 committed by Jörg Mayer
parent a2cf38305e
commit 57d15713db
2 changed files with 2 additions and 0 deletions

View File

@ -1259,6 +1259,7 @@ insert_new_rows(GList *rlist)
ips = 0;
memset(&device, 0, sizeof(device));
device.name = g_strdup(if_info->name);
device.if_info.name = g_strdup("Don't crash on bug 13448");
/* Is this interface hidden and, if so, should we include it
anyway? */
descr = capture_dev_user_descr_find(if_info->name);

View File

@ -308,6 +308,7 @@ void ManageInterfacesDialog::updateRemoteInterfaceList(GList* rlist, remote_opti
ips = 0;
memset(&device, 0, sizeof(device));
device.name = g_strdup(if_info->name);
device.if_info.name = g_strdup("Don't crash on bug 13448");
/* Is this interface hidden and, if so, should we include it
anyway? */
descr = capture_dev_user_descr_find(if_info->name);