Don't allocate to much memory if do_encrypt is not set.
---
suspend.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
Index: suspend/suspend.c
===================================================================
--- suspend.orig/suspend.c 2007-08-16 14:14:44.000000000 +0200
+++ suspend/suspend.c 2007-08-16 15:00:28.000000000 +0200
@@ -1375,16 +1375,6 @@ int main(int argc, char *argv[])
mem_size += LZO1X_1_MEM_COMPRESS;
#endif
#ifdef CONFIG_ENCRYPT
- if (do_encrypt)
- mem_size += buffer_size;
-#endif
- mem_pool = malloc(mem_size);
- if (!mem_pool) {
- ret = errno;
- suspend_error("Could not allocate memory.");
- return ret;
- }
-#ifdef CONFIG_ENCRYPT
if (do_encrypt) {
printf("%s: libgcrypt version: %s\n", my_name,
gcry_check_version(NULL));
@@ -1395,8 +1385,18 @@ int main(int argc, char *argv[])
fprintf(stderr, "%s: libgcrypt error %s\n", my_name,
gcry_strerror(ret));
do_encrypt = 0;
+ } else {
+ mem_size += buffer_size;
}
}
+#endif
+ mem_pool = malloc(mem_size);
+ if (!mem_pool) {
+ ret = errno;
+ suspend_error("Could not allocate memory.");
+ return ret;
+ }
+#ifdef CONFIG_ENCRYPT
if (do_encrypt) {
mem_size -= buffer_size;
key_data = (struct key_data *)((char *)mem_pool + mem_size);
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Suspend-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/suspend-devel