[Vala] Another issue in gnome-keyring
- From: Magnus Therning <magnus therning org>
- To: vala-list <vala-list gnome org>
- Subject: [Vala] Another issue in gnome-keyring
- Date: Sat, 17 Oct 2009 15:32:29 +0100
Here's something else I stumbled on when trying to use gnome-keyring from
Vala. There are some subtle stuff in gnome-keyring relating to memory
management that Vala doesn't seem to obey. The following code:
string pwd;
res = find_password_sync
( NETWORK_PASSWORD
, out pwd
// the attributes
, "user", "me"
, "server", "vala.test"
, 0 );
generates this C code:
pwd = NULL;
res = (_tmp1_ = gnome_keyring_find_password_sync
(gnome_keyring_NETWORK_PASSWORD, &_tmp0_, "user", "me", "server", "vala.test",
0, NULL), pwd = (_tmp2_ = g_strdup (_tmp0_), _g_free0 (pwd), _tmp2_), _tmp1_);
AFAIU this is bad in that the out parameter (_tmp0) is owned by the caller,
duplicating it is unnecessary and creates a memory leak since _tmp0 never is
freed. On top of that pwd is pointing to secret information, and it really
should be freed using gnome_keyring_free_password() rather then g_free().
/M
--
Magnus Therning (OpenPGP: 0xAB4DFBA4)
magnus@therning.org Jabber: magnus@therning.org
http://therning.org/magnus identi.ca|twitter: magthe
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]