Browse code

pdf: rework parse_enc_method

David Raynor authored on 2013/08/08 02:50:08
Showing 1 changed files
... ...
@@ -1851,6 +1851,7 @@ static enum enc_method parse_enc_method(const char *dict, unsigned len, const ch
1851 1851
 {
1852 1852
     const char *q;
1853 1853
     char *CFM = NULL;
1854
+    enum enc_method ret = ENC_UNKNOWN;
1854 1855
     if (!key)
1855 1856
 	return def;
1856 1857
     if (!strcmp(key, "Identity"))
... ...
@@ -1862,24 +1863,20 @@ static enum enc_method parse_enc_method(const char *dict, unsigned len, const ch
1862 1862
     if (CFM) {
1863 1863
 	cli_dbgmsg("cli_pdf: %s CFM: %s\n", key, CFM);
1864 1864
 	if (!strncmp(CFM,"V2", 2)){
1865
-	    free(CFM);	
1866
-	    return ENC_V2;
1865
+	    ret = ENC_V2;
1867 1866
 	}    
1868
-	if (!strncmp(CFM,"AESV2",5)){
1869
-	    free(CFM);	
1870
-	    return ENC_AESV2;
1867
+	else if (!strncmp(CFM,"AESV2",5)){
1868
+	    ret = ENC_AESV2;
1871 1869
 	}    
1872
-	if (!strncmp(CFM,"AESV3",5)){
1873
-	    free(CFM);	
1874
-	    return ENC_AESV3;
1870
+	else if (!strncmp(CFM,"AESV3",5)){
1871
+	    ret = ENC_AESV3;
1875 1872
 	}    
1876
-	if (!strncmp(CFM,"None",4)){
1877
-	    free(CFM);	
1878
-	    return ENC_NONE;
1873
+	else if (!strncmp(CFM,"None",4)){
1874
+	    ret = ENC_NONE;
1879 1875
 	}
1880 1876
 	free(CFM);
1881 1877
     }
1882
-    return ENC_UNKNOWN;
1878
+    return ret;
1883 1879
 }
1884 1880
 
1885 1881
 static void pdf_handle_enc(struct pdf_struct *pdf)