key-attr.c (key_setkeydata): Decref after incref.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 22 Jan 2012 12:56:34 +0000 (12:56 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 22 Jan 2012 13:06:18 +0000 (13:06 +0000)
Otherwise we'd crash if someone set the key data to be itself.

key-attr.c

index ceec2ae..b6a3616 100644 (file)
@@ -194,8 +194,8 @@ int key_setkeydata(key_file *kf, key *k, key_data *kd)
 {
   if (!(kf->f & KF_WRITE))
     return (KERR_READONLY);
 {
   if (!(kf->f & KF_WRITE))
     return (KERR_READONLY);
-  key_drop(k->k);
   key_incref(kd);
   key_incref(kd);
+  key_drop(k->k);
   k->k = kd;
   kf->f |= KF_MODIFIED;
   return (0);
   k->k = kd;
   kf->f |= KF_MODIFIED;
   return (0);