Skip to content
  • Martin's avatar
    Use convert_return_gchar_ptr_to_*() in a couple of ustring methods · 5d634e30
    Martin authored
    First attempt at fixing memory leak in make_valid() (see previous commit)
    used make_unique_ptr_gfree() directly because of looking at these methods.
    Better to use the helper function.
    
    This actually fixes undefined behavior for normalize() since
    g_utf8_normalize() is documented to return NULL if string is not a valid
    UTF-8 string. The constructor for std::string, which ustring uses for
    storage, that takes a pointer is documented to have undefined behavior if
    pointer is NULL. The utility function checks for NULL and uses the default
    constructor in that case. (Have not looked at implementation of Glib
    functions, and it may be that all std::string implementations Glibmm is
    used with handles this case, but good to avoid undefined behavior
    regardless, I think.)
    5d634e30