mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2026-12-05 00:02:27 -08:00
Fix Out of memory for large attachment #115
This commit is contained in:
1 parent
bb3fb26847
commit
9130a3851f
7 files changed
+91
-34
No files matched your search
@@ -63,30 +63,36 @@ public class BinaryPool {
|
||||
@Override
|
||||
public boolean operate(PwEntryV4 entry) {
|
||||
for (PwEntryV4 histEntry : entry.getHistory()) {
|
||||
poolAdd(histEntry.getBinaries());
|
||||
add(histEntry.getBinaries());
|
||||
}
|
||||
poolAdd(entry.getBinaries());
|
||||
add(entry.getBinaries());
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void poolAdd(Map<String, ProtectedBinary> dict) {
|
||||
private void add(Map<String, ProtectedBinary> dict) {
|
||||
for (ProtectedBinary pb : dict.values()) {
|
||||
poolAdd(pb);
|
||||
add(pb);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void poolAdd(ProtectedBinary pb) {
|
||||
assert(pb != null);
|
||||
public void add(ProtectedBinary pb) {
|
||||
assert(pb != null);
|
||||
if (findKey(pb) != -1) return;
|
||||
|
||||
if (poolFind(pb) != -1) return;
|
||||
|
||||
pool.put(pool.size(), pb);
|
||||
pool.put(findUnusedKey(), pb);
|
||||
}
|
||||
|
||||
public int findUnusedKey() {
|
||||
int unusedKey = pool.size();
|
||||
while(get(unusedKey) != null)
|
||||
unusedKey++;
|
||||
return unusedKey;
|
||||
}
|
||||
|
||||
public int poolFind(ProtectedBinary pb) {
|
||||
public int findKey(ProtectedBinary pb) {
|
||||
for (Entry<Integer, ProtectedBinary> pair : pool.entrySet()) {
|
||||
if (pair.getValue().equals(pb)) return pair.getKey();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user