X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/putty/blobdiff_plain/fc9b052a2fc832ea8bc3efa9c79eba0f961830b2..af723f2945eccb9ae3bc44f682457150c97cfa57:/windows/winpgen.c diff --git a/windows/winpgen.c b/windows/winpgen.c index aeebb629..33d76c64 100644 --- a/windows/winpgen.c +++ b/windows/winpgen.c @@ -420,11 +420,11 @@ static int save_ssh1_pubkey(char *filename, struct RSAKey *key) char *dec1, *dec2; FILE *fp; - dec1 = bignum_decimal(key->exponent); - dec2 = bignum_decimal(key->modulus); fp = fopen(filename, "wb"); if (!fp) return 0; + dec1 = bignum_decimal(key->exponent); + dec2 = bignum_decimal(key->modulus); fprintf(fp, "%d %s %s %s\n", bignum_bitcount(key->modulus), dec1, dec2, key->comment); fclose(fp); @@ -954,8 +954,11 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg, /* * Load a key file if one was provided on the command line. */ - if (cmdline_keyfile) - load_key_file(hwnd, state, filename_from_str(cmdline_keyfile), 0); + if (cmdline_keyfile) { + Filename *fn = filename_from_str(cmdline_keyfile); + load_key_file(hwnd, state, fn, 0); + filename_free(fn); + } return 1; case WM_MOUSEMOVE: @@ -1256,9 +1259,11 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg, if (!state->generation_thread_exists) { char filename[FILENAME_MAX]; if (prompt_keyfile(hwnd, "Load private key:", - filename, 0, LOWORD(wParam)==IDC_LOAD)) - load_key_file(hwnd, state, filename_from_str(filename), - LOWORD(wParam) != IDC_LOAD); + filename, 0, LOWORD(wParam)==IDC_LOAD)) { + Filename *fn = filename_from_str(filename); + load_key_file(hwnd, state, fn, LOWORD(wParam) != IDC_LOAD); + filename_free(fn); + } } break; }