diff -urpN john-1.7.8-jumbo-5a/src/john.c john-1.7.8-jumbo-4b/src/john.c
--- john-1.7.8-jumbo-5a/src/john.c	2011-08-03 10:49:21.000000000 -0500
+++ john-1.7.8-jumbo-4b/src/john.c	2011-08-11 17:10:26.921875000 -0500
@@ -78,12 +78,10 @@ extern struct fmt_main fmt_SybaseASE;
 extern struct fmt_main fmt_SKEY;
 #endif
 
-#ifndef _MSC_VER
 extern struct fmt_main fmt_ssh;
 extern struct fmt_main fmt_pdf;
 extern struct fmt_main rar_fmt;
 extern struct fmt_main zip_fmt;
-#endif
 
 #include "fmt_externs.h"
 
@@ -153,12 +151,11 @@ static void john_register_all(void)
 	john_register_one(&fmt_SKEY);
 #endif
 
-#ifndef _MSC_VER
 	john_register_one(&fmt_ssh);
 	john_register_one(&fmt_pdf);
 	john_register_one(&rar_fmt);
 	john_register_one(&zip_fmt);
-#endif
+
 
 	john_register_one(&fmt_dummy);
 
diff -urpN john-1.7.8-jumbo-5a/src/pdf_fmt.c john-1.7.8-jumbo-4b/src/pdf_fmt.c
--- john-1.7.8-jumbo-5a/src/pdf_fmt.c	2011-06-08 11:15:59.000000000 -0500
+++ john-1.7.8-jumbo-4b/src/pdf_fmt.c	2011-08-12 10:18:52.218750000 -0500
@@ -78,23 +78,30 @@ static int valid(char *ciphertext, struc
 
 static void *get_salt(char *ciphertext)
 {
-	char *copy = strdup(ciphertext);
+	static char copy[SALT_SIZE+1];
+	//char *copy = strdup(ciphertext);  // this causes a crash in debugging MSVC, due to reading past the end of this allocated buffer.  The 'static' is the proper size.
+	strcpy(copy, ciphertext);
 	return (void *) copy;
 }
 
-static void set_salt(void *salt)
+static void set_salt(void *_salt)
 {
+	unsigned char *salt = (unsigned char*)_salt;
+	int i;
+	char *p;
+	unsigned char *copy;
+	unsigned char *userpassword = NULL;
+
 #ifdef PDF_FMT_DEBUG
 	printf("%s\n", (char *)salt);
 #endif
 	salt += 5;		/* skip over "$pdf$" marker */
-	int i;
-	char *p;
-	char *copy = strdup(salt);
-	unsigned char *userpassword = NULL;
+	copy = (unsigned char*)strdup((char*)salt);
+
+	freeEncData(&e, 1);
 
 	/* restore serialized data */
-	e.s_handler = strdup(strtok(copy, "*"));
+	e.s_handler = strdup(strtok((char*)copy, "*"));
 	e.o_string = (uint8_t *) malloc(32);
 	p = strtok(NULL, "*");
 	for (i = 0; i < 32; i++)
@@ -146,6 +153,7 @@ static void set_salt(void *salt)
 		fprintf(stderr, "Wrong userpassword, '%s'\n", userpassword);
 		exit(-1);
 	}
+	free(copy);
 }
 
 static void pdf_set_key(char *key, int index)
diff -urpN john-1.7.8-jumbo-5a/src/pdfcrack.c john-1.7.8-jumbo-4b/src/pdfcrack.c
--- john-1.7.8-jumbo-5a/src/pdfcrack.c	2011-07-02 15:17:15.000000000 -0500
+++ john-1.7.8-jumbo-4b/src/pdfcrack.c	2011-08-12 10:32:06.484375000 -0500
@@ -18,7 +18,7 @@
  * USA.
  */
 
-#include <stdbool.h>
+#include "stdbool.h"
 #include "stdint.h"
 #include <stdlib.h>
 #include <string.h>
@@ -28,6 +28,14 @@
 #include "pdfcrack_md5.h"
 #include "pdfcrack_rc4.h"
 
+#ifdef _MSC_VER
+#define likely(x)       (x)
+#define unlikely(x)     (x)
+#else
+#define likely(x)       __builtin_expect((x),1)
+#define unlikely(x)     __builtin_expect((x),0)
+#endif
+
 /** sets the number of bytes to decrypt for partial test in revision 3.
     Three should be a good number for this as this mean a match should only
     happen every 256^3=16777216 check and that should be unique enough to
@@ -48,6 +56,9 @@ static uint8_t password_user[33];
 static uint8_t *rev3TestKey;
 static unsigned int ekwlen;
 
+/* flag used to make sure we do not clean up when we have not called init */
+static int binitPDFCrack_called = 0;
+
 /** points to the current password in clear-text */
 static unsigned char *currPW;
 /** current length of the password we are working with */
@@ -357,6 +368,9 @@ int runCrack(char *password)
 */
 void cleanPDFCrack(void)
 {
+	if (!binitPDFCrack_called)
+		return;
+	binitPDFCrack_called = 0;
 	if (rev3TestKey) {
     /** Do a really ugly const to non-const cast but this one time it should
 	be safe
@@ -381,6 +395,11 @@ bool initPDFCrack(const EncData * e, con
 	unsigned int upwlen;
 	uint8_t *tmp;
 
+	/* cleans up before we start */
+	cleanPDFCrack();
+	/* set that we 'have' called init, and to allow cleanup to work next time */
+	binitPDFCrack_called = 1;
+
 	ekwlen =
 	    initEncKeyWorkSpace(e->revision, e->encryptMetaData,
 	    e->permissions, e->o_string, e->fileID, e->fileIDLen);
diff -urpN john-1.7.8-jumbo-5a/src/pdfcrack_common.c john-1.7.8-jumbo-4b/src/pdfcrack_common.c
--- john-1.7.8-jumbo-5a/src/pdfcrack_common.c	2011-06-07 19:54:18.000000000 -0500
+++ john-1.7.8-jumbo-4b/src/pdfcrack_common.c	2011-08-12 09:56:34.546875000 -0500
@@ -21,19 +21,30 @@
 #include <stdlib.h>
 #include "pdfcrack_common.h"
 
-void freeEncData(EncData * e)
+void freeEncData(EncData * e, int static_object)
 {
 	if (!e)
 		return;
-	if (e->o_string)
+	if (e->o_string) {
 		free(e->o_string);
-	if (e->u_string)
+		e->o_string = NULL;
+	}
+	if (e->u_string) {
 		free(e->u_string);
-	if (e->fileID)
+		e->u_string = NULL;
+	}
+	if (e->fileID) {
 		free(e->fileID);
-	if (e->s_handler)
+		e->fileID = NULL;
+	}
+	if (e->s_handler) {
 		free(e->s_handler);
-	free(e);
+		e->s_handler = NULL;
+	}
+	if (!static_object)
+		free(e);
+//	else
+//		memset(e, 0, sizeof(*E));
 }
 
 void printEncData(EncData * e)
diff -urpN john-1.7.8-jumbo-5a/src/pdfcrack_common.h john-1.7.8-jumbo-4b/src/pdfcrack_common.h
--- john-1.7.8-jumbo-5a/src/pdfcrack_common.h	2011-07-02 15:17:15.000000000 -0500
+++ john-1.7.8-jumbo-4b/src/pdfcrack_common.h	2011-08-12 10:01:43.093750000 -0500
@@ -21,10 +21,7 @@
 #define _PDFCOMMON_H_
 
 #include "stdint.h"
-#include <stdbool.h>
-
-#define likely(x)       __builtin_expect((x),1)
-#define unlikely(x)     __builtin_expect((x),0)
+#include "stdbool.h"
 
 /**
     EncData holds all the information regarding the encryption-setting of a
@@ -51,7 +48,7 @@ typedef struct EncData {
 	int version;
 } EncData;
 
-void freeEncData(EncData * e);
+void freeEncData(EncData * e, int is_static_object);
 
 void printEncData(EncData * e);
 
diff -urpN john-1.7.8-jumbo-5a/src/pdfcrack_rc4.c john-1.7.8-jumbo-4b/src/pdfcrack_rc4.c
--- john-1.7.8-jumbo-5a/src/pdfcrack_rc4.c	2011-06-07 19:54:18.000000000 -0500
+++ john-1.7.8-jumbo-4b/src/pdfcrack_rc4.c	2011-08-11 09:55:45.921875000 -0500
@@ -20,8 +20,17 @@
 #include <assert.h>
 #include "pdfcrack_rc4.h"
 
+
+#ifdef _MSC_VER
+#define ATTR_PURE
+#define inline _inline
+#define likely(x)       (x)
+#define unlikely(x)     (x)
+#else
+#define ATTR_PURE __attribute__ ((pure))
 #define likely(x)       __builtin_expect((x),1)
 #define unlikely(x)     __builtin_expect((x),0)
+#endif
 
 /** Seems to faster to do a memcpy of this on my machine than to create
     the array with a loop
@@ -59,7 +68,7 @@ initial_state[256] = {
   }
 
 /** Do rc4-decrypt with key on bs of length 32 and compare it to match */
-__attribute__ ((pure)) bool
+ATTR_PURE bool
 rc4Match40b(const uint8_t *key, const uint8_t *bs,const uint8_t *match) {
   uint8_t state[256];
   register unsigned int i;
@@ -194,14 +203,14 @@ rc4Decrypt128b(const uint8_t *key, const
 }
 
 /** Just a wrapper for the function optimized for a specific length */
-inline void
+void
 rc4Decrypt(const uint8_t *key, const uint8_t *bs,
 	   const unsigned int len, uint8_t *out) {
   rc4d(key, bs, len, out);
 }
 
 /** sets which function the wrapper should call */
-__attribute__ ((pure)) bool
+ATTR_PURE bool
 setrc4DecryptMethod(const unsigned int length) {
   if(length == 128)
     rc4d = &rc4Decrypt128b;
diff -urpN john-1.7.8-jumbo-5a/src/pdfcrack_rc4.h john-1.7.8-jumbo-4b/src/pdfcrack_rc4.h
--- john-1.7.8-jumbo-5a/src/pdfcrack_rc4.h	2011-07-02 15:17:15.000000000 -0500
+++ john-1.7.8-jumbo-4b/src/pdfcrack_rc4.h	2011-08-11 09:48:48.859375000 -0500
@@ -20,7 +20,7 @@
 #ifndef _RC4_H_
 #define _RC4_H_
 #include "stdint.h"
-#include <stdbool.h>
+#include "stdbool.h"
 
 void
 rc4Decrypt(const uint8_t *key, const uint8_t *bs,
diff -urpN john-1.7.8-jumbo-5a/src/pdfparser.c john-1.7.8-jumbo-4b/src/pdfparser.c
--- john-1.7.8-jumbo-5a/src/pdfparser.c	2011-06-07 19:54:55.000000000 -0500
+++ john-1.7.8-jumbo-4b/src/pdfparser.c	2011-08-12 09:56:34.718750000 -0500
@@ -23,6 +23,13 @@
 
 #define BUFFSIZE 256
 
+#ifdef _MSC_VER
+#define ATTR_PURE
+#define inline _inline
+#else
+#define ATTR_PURE __attribute__ ((pure))
+#endif
+
 /** Please rewrite all of this file in a clean and stable way */
 
 struct p_str {
@@ -32,12 +39,12 @@ struct p_str {
 
 typedef struct p_str p_str;
 
-__attribute__ ((pure)) static inline bool
+ATTR_PURE static inline bool
 isWhiteSpace(const int ch) {
   return (ch == 0x20 || (ch >= 0x09 && ch <= 0x0d) || ch == 0x00);
 }
 
-__attribute__ ((pure)) static bool
+ATTR_PURE static bool
 isDelimiter(const int ch) {
   switch(ch) {
   case '(':
@@ -56,7 +63,7 @@ isDelimiter(const int ch) {
   }
 }
 
-__attribute__ ((pure)) static inline bool
+ATTR_PURE static inline bool
 isEndOfLine(const int ch) {
   return (ch == 0x0a || ch == 0x0d);
 }
@@ -180,7 +187,7 @@ openPDF(FILE *file, EncData *e) {
   return ret;
 }
 
-__attribute__ ((pure)) static uint8_t
+ATTR_PURE static uint8_t
 hexToInt(const int b) {
   if(b >= '0' && b <= '9')
     return b-'0';
@@ -214,7 +221,7 @@ static p_str*
 objStringToByte(const uint8_t* str, const unsigned int len) {
   unsigned int i, j, l;
   uint8_t b, d;
-  uint8_t tmp[len];
+  uint8_t tmp[BUFFSIZE];
   p_str *ret;
 
   for(i=0, l=0; i<len; i++, l++) {
@@ -385,6 +392,7 @@ findTrailer(FILE *file, EncData *e) {
 		if(str->content)
 		  free(str->content);
 		free(str);
+		str = NULL;
 	      }
 
 	      str = parseRegularString(file);
@@ -491,6 +499,12 @@ parseEncrypObject(FILE *file, EncData *e
 	}
 	break;
       case 'O':
+	if(str) {
+		if(str->content)
+			free(str->content);
+		free(str);
+		str = NULL;
+	}
 	str = parseRegularString(file);
 	if(!str)
 	  break;
@@ -498,6 +512,7 @@ parseEncrypObject(FILE *file, EncData *e
 	  fprintf(stderr, "WARNING: O-String != 32 Bytes: %d\n", str->len);
 	e->o_string = str->content;
 	free(str);
+	str = NULL;
 	fo = true;
 	break;
       case 'P':
@@ -517,6 +532,12 @@ parseEncrypObject(FILE *file, EncData *e
 	}
 	break;
       case 'U':
+	if(str) {
+		if(str->content)
+			free(str->content);
+		free(str);
+		str = NULL;
+	}
 	str = parseRegularString(file);
 	if(!str)
 	  break;
@@ -524,6 +545,7 @@ parseEncrypObject(FILE *file, EncData *e
 	  fprintf(stderr, "WARNING: U-String != 32 Bytes: %d\n", str->len);
 	e->u_string = str->content;
 	free(str);
+	str = NULL;
 	fu = true;
 	break;
       case 'V':
diff -urpN john-1.7.8-jumbo-5a/src/pdfparser.h john-1.7.8-jumbo-4b/src/pdfparser.h
--- john-1.7.8-jumbo-5a/src/pdfparser.h	2011-07-02 15:17:15.000000000 -0500
+++ john-1.7.8-jumbo-4b/src/pdfparser.h	2011-08-11 09:41:27.531250000 -0500
@@ -21,7 +21,7 @@
 #define _PDFPARSER_H_
 #include <stdio.h>
 #include "stdint.h"
-#include <stdbool.h>
+#include "stdbool.h"
 #include "pdfcrack_common.h"
 
 #define EENCNF -1 /* Encryption Object Not Found */
diff -urpN john-1.7.8-jumbo-5a/src/rar_fmt.c john-1.7.8-jumbo-4b/src/rar_fmt.c
--- john-1.7.8-jumbo-5a/src/rar_fmt.c	2011-07-02 16:08:49.000000000 -0500
+++ john-1.7.8-jumbo-4b/src/rar_fmt.c	2011-08-11 09:28:39.312500000 -0500
@@ -94,10 +94,11 @@ static void set_salt(void *salt)
 {
 	int i, count;
 	/* extract data from "salt" */
+	char *encoded_salt;
 	char *saltcopy = strdup(salt);
 	saltcopy += 7;		/* skip over "$rar3$*" */
 	type = atoi(strtok(saltcopy, "*"));
-	char *encoded_salt = strtok(NULL, "*");
+	encoded_salt = strtok(NULL, "*");
 	for (i = 0; i < 8; i++)
 		saved_salt[i] = atoi16[ARCH_INDEX(encoded_salt[i * 2])] * 16
 		    + atoi16[ARCH_INDEX(encoded_salt[i * 2 + 1])];
@@ -107,16 +108,18 @@ static void set_salt(void *salt)
 			saved_ct[i] = atoi16[ARCH_INDEX(encoded_ct[i * 2])]
 			    * 16 + atoi16[ARCH_INDEX(encoded_ct[i * 2 + 1])];
 	} else {
+		char *filename;
+		long pos;
+		FILE *fp;
 		char *p = strtok(NULL, "*");
 		for (i = 0; i < 4; i++)
 			FILE_CRC[i] = atoi16[ARCH_INDEX(p[i * 2])] * 16 +
 			    atoi16[ARCH_INDEX(p[i * 2 + 1])];
 		PACK_SIZE = atoi(strtok(NULL, "*"));
 		UNP_SIZE = atoi(strtok(NULL, "*"));
-		char *filename = strtok(NULL, "*");
-		long pos = atol(strtok(NULL, "*"));
+		filename = strtok(NULL, "*");
+		pos = atol(strtok(NULL, "*"));
 		/* load ciphertext */
-		FILE *fp;
 		if (!(fp = fopen(filename, "rb"))) {
 			fprintf(stderr, "! %s : %s\n", filename,
 			    strerror(errno));
@@ -155,6 +158,15 @@ static void crypt_all(int count)
 
 	/* UCS-2 encode the password */
 	char encoded_key[2 * PLAINTEXT_LENGTH];
+	int plen = 2 * strlen(saved_key);
+	unsigned char RawPsw[2*PLAINTEXT_LENGTH + 8];
+	unsigned char aes_key[16];
+	unsigned char aes_iv[16];
+	int RawLength = plen + 8;
+	SHA_CTX ctx;
+	const int HashRounds = 0x40000;
+	unsigned int digest[5];
+
 	memset(encoded_key, 0, 2 * PLAINTEXT_LENGTH);
 	for (i = 0; i < strlen(saved_key); i++) {
 		encoded_key[j] = saved_key[i];
@@ -163,19 +175,13 @@ static void crypt_all(int count)
 
 	/* derive IV and key for AES from saved_key and saved_salt,
 	 * this code block is based on unrarhp's and unrar's sources */
-	int plen = 2 * strlen(saved_key);
-	unsigned char RawPsw[plen + 8];
-	unsigned char aes_key[16];
-	unsigned char aes_iv[16];
-	int RawLength = plen + 8;
-	SHA_CTX ctx;
+
 	memcpy(RawPsw, encoded_key, plen);
 	memcpy(RawPsw + plen, saved_salt, 8);
 	SHA1_Init(&ctx);
-	const int HashRounds = 0x40000;
 	for (i = 0; i < HashRounds; i++) {
-		SHA1_Update(&ctx, RawPsw, RawLength);
 		unsigned char PswNum[3];
+		SHA1_Update(&ctx, RawPsw, RawLength);
 		PswNum[0] = (unsigned char) i;
 		PswNum[1] = (unsigned char) (i >> 8);
 		PswNum[2] = (unsigned char) (i >> 16);
@@ -190,7 +196,6 @@ static void crypt_all(int count)
 			    (unsigned char) digest[4];
 		}
 	}
-	unsigned int digest[5];
 	SHA1_Final((unsigned char *) digest, &ctx);
 	for (j = 0; j < 5; j++)	/* reverse byte order */
 		digest[j] = BYTESWAP32(digest[j]);
@@ -201,10 +206,11 @@ static void crypt_all(int count)
 
 	if (type == 0) {	/* use Marc's method for -hp mode */
 		char ct[16];
-		memcpy(ct, saved_ct, 16);
-		/* AES decrypt, uses aes_iv, aes_key and saved_ct */
 		AES_KEY key;
 		unsigned char output[16];
+
+		memcpy(ct, saved_ct, 16);
+		/* AES decrypt, uses aes_iv, aes_key and saved_ct */
 		AES_set_decrypt_key((unsigned char *) aes_key, 16 * 8, &key);	/* AES-128 */
 		AES_cbc_encrypt((unsigned char *) ct, output, 16, &key,
 		    (unsigned char *) aes_iv, AES_DECRYPT);
diff -urpN john-1.7.8-jumbo-5a/src/ssh_fmt.c john-1.7.8-jumbo-4b/src/ssh_fmt.c
--- john-1.7.8-jumbo-5a/src/ssh_fmt.c	2011-07-02 16:08:58.000000000 -0500
+++ john-1.7.8-jumbo-4b/src/ssh_fmt.c	2011-08-11 09:59:00.531250000 -0500
@@ -83,17 +83,26 @@ static int valid(char *ciphertext, struc
 
 static void *get_salt(char *ciphertext)
 {
-	int i;
+	int i, filelength;
+	char *decoded_data;
 	char *copy = strdup(ciphertext);
 	char *encoded_data = strtok(copy, "*");
+	BIO *bp;
+	char *nm = NULL, *header = NULL;
+	unsigned char *data = NULL;
+	EVP_CIPHER_INFO cipher;
+	EVP_PKEY pk;
+	long len;
+	static struct custom_salt cs;
+
 	if (!copy || !encoded_data) {
 		fprintf(stderr, "BUG in parsing ciphertext, aborting!\n");
 		exit(-1);
 	}
-	int filelength = atoi(strtok(NULL, "*"));
+	filelength = atoi(strtok(NULL, "*"));
 	encoded_data += 6;	/* skip over "$ssh2$ marker */
 	/* decode base64 data */
-	char *decoded_data = (char *) malloc(filelength + 1);
+	decoded_data = (char *) malloc(filelength + 1);
 	for (i = 0; i < filelength; i++)
 		decoded_data[i] =
 		    atoi16[ARCH_INDEX(encoded_data[i * 2])] * 16 +
@@ -101,7 +110,7 @@ static void *get_salt(char *ciphertext)
 	decoded_data[filelength] = 0;
 
 	/* load decoded data into OpenSSL structures */
-	BIO *bp = BIO_new(BIO_s_mem());
+	bp = BIO_new(BIO_s_mem());
 	if (!bp) {
 		fprintf(stderr, "OpenSSL BIO allocation failure\n");
 		exit(-2);
@@ -110,11 +119,6 @@ static void *get_salt(char *ciphertext)
 
 	/* PEM_bytes_read_bio function in crypto/pem/pem_lib.c
 	 * check_pem function in crypto/pem/pem_lib.c */
-	char *nm = NULL, *header = NULL;
-	unsigned char *data = NULL;
-	EVP_CIPHER_INFO cipher;
-	EVP_PKEY pk;
-	long len;
 	for (;;) {
 		if (!PEM_read_bio(bp, &nm, &header, &data, &len)) {
 			if (ERR_GET_REASON(ERR_peek_error()) ==
@@ -148,7 +152,6 @@ static void *get_salt(char *ciphertext)
 #endif
 
 	/* save custom_salt information */
-	static struct custom_salt cs;
 	memset(&cs, 0, sizeof(cs));
 	memcpy(&cs.cipher, &cipher, sizeof(cipher));
 	memcpy(&cs.pk, &pk, sizeof(pk));
@@ -197,12 +200,13 @@ static void crypt_all(int count)
 		/* copy restored items into working copy */
 		unsigned char working_data[4096];
 		long working_len = restored_custom_salt->len;
-		memcpy(working_data, restored_custom_salt->data, working_len);
 		EVP_CIPHER_INFO cipher = restored_custom_salt->cipher;
 		EVP_PKEY pk = restored_custom_salt->pk;
 		const char unsigned *dc = working_data;
 		DSA *dsapkc = NULL;
 		RSA *rsapkc = NULL;
+
+		memcpy(working_data, restored_custom_salt->data, working_len);
 		if (PEM_do_header(&cipher, working_data, &working_len, NULL,
 			(char *) saved_key[index])) {
 			if (pk.save_type == EVP_PKEY_DSA) {
diff -urpN john-1.7.8-jumbo-5a/src/stdbool.h john-1.7.8-jumbo-4b/src/stdbool.h
--- john-1.7.8-jumbo-5a/src/stdbool.h	1969-12-31 18:00:00.000000000 -0600
+++ john-1.7.8-jumbo-4b/src/stdbool.h	2011-08-11 09:43:09.281250000 -0500
@@ -0,0 +1,21 @@
+#ifndef _STDBOOL_H
+#ifdef __STDC_VERSION__
+#include <stdbool.h>
+#else
+
+#define _STDBOOL_H
+
+#ifdef _MSC_VER
+#define bool	unsigned
+#else
+#define bool	_Bool
+#endif
+
+#define true	1
+#define false	0
+/* Signal that all the definitions are present.  */
+#define __bool_true_false_are_defined	1
+
+#endif
+#endif
+
diff -urpN john-1.7.8-jumbo-5a/src/zip_fmt.c john-1.7.8-jumbo-4b/src/zip_fmt.c
--- john-1.7.8-jumbo-5a/src/zip_fmt.c	2011-07-23 17:14:36.000000000 -0500
+++ john-1.7.8-jumbo-4b/src/zip_fmt.c	2011-08-11 17:08:10.250000000 -0500
@@ -41,7 +41,7 @@
 
 static char saved_key[MAX_KEYS_PER_CRYPT][PLAINTEXT_LENGTH + 1];
 static int has_been_cracked[MAX_KEYS_PER_CRYPT];
-static unsigned char *saved_salt;
+static unsigned char saved_salt[48];
 static unsigned char passverify[2];
 static int type;		/* type of zip file */
 static int mode;
@@ -65,14 +65,15 @@ static void *get_salt(char *ciphertext)
 
 static void set_salt(void *salt)
 {
-	int i;
+	int i, strength, n;
 	/* extract data from "salt" */
+	char *encoded_salt, *p;
 	char *saltcopy_mem = strdup(salt);
 	char *saltcopy = saltcopy_mem + 6; /* skip over "$zip$*" */
+
 	type = atoi(strtok(saltcopy, "*"));
-	int strength = atoi(strtok(NULL, "*"));
+	strength = atoi(strtok(NULL, "*"));
 	mode = strength;
-	int n;
 	switch (strength) {
 	case 1:
 		n = 8;
@@ -88,13 +89,11 @@ static void set_salt(void *salt)
 		error();
 		n = 0; /* Not reached */
 	}
-	char *encoded_salt = strtok(NULL, "*");
-	free(saved_salt);
-	saved_salt = malloc(n);
+	encoded_salt = strtok(NULL, "*");
 	for (i = 0; i < n; i++)
 		saved_salt[i] = atoi16[ARCH_INDEX(encoded_salt[i * 2])] * 16
 		    + atoi16[ARCH_INDEX(encoded_salt[i * 2 + 1])];
-	char *p = strtok(NULL, "*");
+	p = strtok(NULL, "*");
 	for (i = 0; i < 2; i++)
 		passverify[i] = atoi16[ARCH_INDEX(p[i * 2])] * 16 +
 		    atoi16[ARCH_INDEX(p[i * 2 + 1])];
