Comment 4 for bug 400839

Revision history for this message
hyperqbe (hyperqbe) wrote :

Perhaps I should explain the patch. The problem was that g_strstrip() was being called on the result of gtk_entry_get_text() for the username and password fields. Normally this might not be a problem, but when a GtkEntry has not been modified, gtk_entry_get_text() will return "". That is, the *constant* string "". g_strstrip("") segfaults.

There are many possible solutions to this. One could check for the special case of an empty string, but that felt like a bit of a difficult to explain hack. The option I took was to call g_strdup() on the two strings. This requires the caller of the uc_utils_get_auth_fields() function to g_free these strings. However, uc_utils_get_auth_fields() already requires the caller to g_free one of the three strings it returns. Requiring the caller to g_free the other two makes the interface more consistent.

So the patch adds the calls to g_strdup(), and whereever uc_utils_get_auth_fields() is called (twice), we add g_free() calls to free the new strings.