diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2022-10-22 11:27:23 +0200 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2022-10-22 13:59:05 +0200 |
commit | b5acaa1cf36c30ab3cb1a2796ead850598ed233f (patch) | |
tree | 04eae9ee9e86c42e0957c0b1fcd6586b80399e29 /libreofficekit/qa | |
parent | 66ac4d9171fee9d425d3301933c1eb8e85c25933 (diff) |
g_get_real_name is a proper match for passwd::pw_gecos
This fixes 66fcc9db0f7eacd0ebda06d9ee634af2d0e73d04. Also nullptr check
is added (passing nullptr to std::string ctor taking null-terminated
string is UB).
GLib implementation:
* https://gitlab.gnome.org/GNOME/glib/-/blob/476e33c3f3632bd32370fadc67b10d61da9a4098/glib/gutils.c#L743
* https://gitlab.gnome.org/GNOME/glib/-/blob/476e33c3f3632bd32370fadc67b10d61da9a4098/glib/gutils.c#L577
Change-Id: I4e36cf836f2889f9aa03167c5ade81c69d9b1dfd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141586
Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'libreofficekit/qa')
-rw-r--r-- | libreofficekit/qa/gtktiledviewer/gtv-helpers.cxx | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-helpers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-helpers.cxx index 109b0946366a..f2c1e9b9351a 100644 --- a/libreofficekit/qa/gtktiledviewer/gtv-helpers.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtv-helpers.cxx @@ -92,7 +92,9 @@ void GtvHelpers::clipboardSetHtml(GtkClipboard* pClipboard, const char* pSelecti std::string GtvHelpers::getNextAuthor() { static int nCounter = 0; - return std::string(g_get_user_name()) + " #" + std::to_string(++nCounter); + const gchar* pname = g_get_real_name(); + std::string name = pname ? std::string(pname) : std::string(); + return name + " #" + std::to_string(++nCounter); } GtkWidget* GtvHelpers::createCommentBox(const boost::property_tree::ptree& aComment) |