X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=mac%2Fmacstore.c;h=35f31bdbcedc79ff57896172496f91af80d27f1f;hb=182a511ec3dce0b726be5df4e8e16af605ec4f6a;hp=74fa8d972493d213cf073bf1b585570ec2dac4f7;hpb=3fa46caeb83772c2bbf9dbab0f50ca355390e577;p=PuTTY.git diff --git a/mac/macstore.c b/mac/macstore.c index 74fa8d97..35f31bdb 100644 --- a/mac/macstore.c +++ b/mac/macstore.c @@ -506,10 +506,10 @@ void *enum_settings_start(void) { OSErr error; struct enum_settings_state *state; - state = safemalloc(sizeof(*state)); + state = snew(struct enum_settings_state); error = get_session_dir(kDontCreateFolder, &state->vRefNum, &state->dirID); if (error != noErr) { - safefree(state); + sfree(state); return NULL; } state->index = 1; @@ -683,6 +683,7 @@ void store_host_key(const char *hostname, int port, char *resname; Str255 presname; Handle resvalue; + Handle reshandle; int id; /* Open the host key file */ @@ -708,7 +709,12 @@ void store_host_key(const char *hostname, int port, UseResFile(keyrefnum); resname = dupprintf("%s@%d:%s", keytype, port, hostname); c2pstrcpy(presname, resname); - + + reshandle = Get1NamedResource(FOUR_CHAR_CODE('TEXT'), presname); + if (reshandle != NULL) { + /* The resource exists, we're replacing a host key */ + RemoveResource(reshandle); + } error = PtrToHand(key, &resvalue, strlen(key)); if (error != noErr) goto out;