Use unique_xmalloc_ptr in Python code
[deliverable/binutils-gdb.git] / gdb / python / py-type.c
index da9dadd2fb07be053d7c75660cd4a506144909d9..17fa297960bc9f2c9cb794e8a8c16f53c5d686b0 100644 (file)
@@ -1197,10 +1197,9 @@ static PyObject *
 typy_getitem (PyObject *self, PyObject *key)
 {
   struct type *type = ((type_object *) self)->type;
-  char *field;
   int i;
 
-  field = python_string_to_host_string (key);
+  gdb::unique_xmalloc_ptr<char> field = python_string_to_host_string (key);
   if (field == NULL)
     return NULL;
 
@@ -1216,7 +1215,7 @@ typy_getitem (PyObject *self, PyObject *key)
     {
       const char *t_field_name = TYPE_FIELD_NAME (type, i);
 
-      if (t_field_name && (strcmp_iw (t_field_name, field) == 0))
+      if (t_field_name && (strcmp_iw (t_field_name, field.get ()) == 0))
        {
          return convert_field (type, i);
        }
This page took 0.023556 seconds and 4 git commands to generate.