aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2016-05-28 09:27:45 +0000
committerWerner Koch <[email protected]>2016-06-15 09:24:43 +0000
commitbaf4bcc0973c8b04bd760aaab0f4232c9354e203 (patch)
treea2ec1796091467a68ede198da560f49128b46094
parentAdd GPG_ERR_SUBKEYS_EXP_OR_REV. (diff)
downloadlibgpg-error-baf4bcc0973c8b04bd760aaab0f4232c9354e203.tar.gz
libgpg-error-baf4bcc0973c8b04bd760aaab0f4232c9354e203.zip
Adjust memory limit of es_fopenmem to the block size.
* src/estream.c (func_mem_create): Round up memory limit. -- This is required so that giving a memory limit to es_fopenmem won't fail if it is below the block size. Signed-off-by: Werner Koch <[email protected]>
-rw-r--r--src/estream.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/estream.c b/src/estream.c
index 499cc75..2033b23 100644
--- a/src/estream.c
+++ b/src/estream.c
@@ -639,6 +639,14 @@ func_mem_create (void *_GPGRT__RESTRICT *_GPGRT__RESTRICT cookie,
return -1;
}
+ /* Round a memory limit up to the next block length. */
+ if (memory_limit && block_size)
+ {
+ memory_limit += block_size - 1;
+ memory_limit /= block_size;
+ memory_limit *= block_size;
+ }
+
mem_cookie = mem_alloc (sizeof (*mem_cookie));
if (!mem_cookie)
err = -1;