Use unique_xmalloc_ptr in Python code
[deliverable/binutils-gdb.git] / gdb / python / py-varobj.c
index a6b1968aefd339f6eca472d3571ef0e8f7fc3531..72c876ce82a0415a62f19cdd4f93e7755a95e670 100644 (file)
@@ -75,10 +75,11 @@ py_varobj_iter_next (struct varobj_iter *self)
       if (PyErr_ExceptionMatches (gdbpy_gdb_memory_error))
        {
          PyObject *type, *value, *trace;
-         char *name_str, *value_str;
+         char *name_str;
 
          PyErr_Fetch (&type, &value, &trace);
-         value_str = gdbpy_exception_to_string (type, value);
+         gdb::unique_xmalloc_ptr<char>
+           value_str (gdbpy_exception_to_string (type, value));
          Py_XDECREF (type);
          Py_XDECREF (value);
          Py_XDECREF (trace);
@@ -90,9 +91,8 @@ py_varobj_iter_next (struct varobj_iter *self)
 
          name_str = xstrprintf ("<error at %d>",
                                 self->next_raw_index++);
-         item = Py_BuildValue ("(ss)", name_str, value_str);
+         item = Py_BuildValue ("(ss)", name_str, value_str.get ());
          xfree (name_str);
-         xfree (value_str);
          if (item == NULL)
            {
              gdbpy_print_stack ();
This page took 0.023722 seconds and 4 git commands to generate.