[2/2] config: Don't free memory in PARSING_USER_CONF

Submitted by Radostin Stoyanov on Jan. 19, 2019, 5:23 p.m.

Details

Message ID 20190119172314.16477-2-rstoyanov1@gmail.com
State New
Series "Series without cover letter"
Headers show

Commit Message

Radostin Stoyanov Jan. 19, 2019, 5:23 p.m.
On restore, when state=PARSING_USER_CONF the _argv pointer
points to the location which contains the envirnment variables
and should not be free()-ed.

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
---
 criu/config.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/criu/config.c b/criu/config.c
index 89afdd748..f3c8d4254 100644
--- a/criu/config.c
+++ b/criu/config.c
@@ -509,7 +509,7 @@  int parse_options(int argc, char **argv, bool *usage_error,
 		/* Only if opt is -1 we are going to the next configuration input */
 		if (opt == -1) {
 			/* Do not free any memory if it points to argv */
-			if (state != PARSING_ARGV + 1) {
+			if (state != PARSING_ARGV + 1 && state != PARSING_USER_CONF) {
 				int i;
 				for (i=1; i < _argc; i++) {
 					free(_argv[i]);

Comments

Radostin Stoyanov Jan. 19, 2019, 6:11 p.m.
On 19/01/2019 17:23, Radostin Stoyanov wrote:
> On restore, when state=PARSING_USER_CONF the _argv pointer
> points to the location which contains the envirnment variables
> and should not be free()-ed.
>
> Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
> ---
>  criu/config.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/criu/config.c b/criu/config.c
> index 89afdd748..f3c8d4254 100644
> --- a/criu/config.c
> +++ b/criu/config.c
> @@ -509,7 +509,7 @@ int parse_options(int argc, char **argv, bool *usage_error,
>  		/* Only if opt is -1 we are going to the next configuration input */
>  		if (opt == -1) {
>  			/* Do not free any memory if it points to argv */
> -			if (state != PARSING_ARGV + 1) {
> +			if (state != PARSING_ARGV + 1 && state != PARSING_USER_CONF) {
>  				int i;
>  				for (i=1; i < _argc; i++) {
>  					free(_argv[i]);
I sent this patch because I am getting the error:

(00.000000) Unable to get $HOME directory, local configuration file will
not be used.
(00.000014) Warn  (criu/log.c:203): The early log isn't empty
(00.000022) Version: 3.11 (gitid
v3.11-125-g93043916c)                        

On Arch Linux with kernel version 5.0.0-rc2-g6b529fb0a3ea
However, I just noticed that the error does not reproduce on Fedora 29.
I will continue to investigate.

Radostin