mirror of
https://github.com/status-im/sqlcipher.git
synced 2025-02-22 08:48:10 +00:00
alter realloc logic to allocate and lock new segment with memory security on
This commit is contained in:
parent
3399ace246
commit
5db049f916
@ -95,8 +95,20 @@ static void sqlcipher_mem_free(void *p) {
|
||||
default_mem_methods.xFree(p);
|
||||
}
|
||||
static void *sqlcipher_mem_realloc(void *p, int n) {
|
||||
return default_mem_methods.xRealloc(p, n);
|
||||
void *new = NULL;
|
||||
if(mem_security_on) {
|
||||
new = sqlcipher_mem_malloc(n);
|
||||
if(new == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
memcpy(new, p, n);
|
||||
sqlcipher_mem_free(p);
|
||||
return new;
|
||||
} else {
|
||||
return default_mem_methods.xRealloc(p, n);
|
||||
}
|
||||
}
|
||||
|
||||
static int sqlcipher_mem_roundup(int n) {
|
||||
return default_mem_methods.xRoundup(n);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user