tools/env: Fix variable delete operation

Fix crash introduced by a073d63a36524453a817ab029fad5b188f46127e
when attempting to delete a variable.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
master
Joe Hershberger 12 years ago committed by Tom Rini
parent bd23b22bad
commit ce2f580017
  1. 5
      tools/env/fw_env.c

@ -494,6 +494,8 @@ int fw_setenv(int argc, char *argv[])
char *val = argv[i]; char *val = argv[i];
size_t val_len = strlen(val); size_t val_len = strlen(val);
if (value)
value[len - 1] = ' ';
value = realloc(value, len + val_len + 1); value = realloc(value, len + val_len + 1);
if (!value) { if (!value) {
fprintf(stderr, fprintf(stderr,
@ -504,9 +506,8 @@ int fw_setenv(int argc, char *argv[])
memcpy(value + len, val, val_len); memcpy(value + len, val, val_len);
len += val_len; len += val_len;
value[len++] = ' '; value[len++] = '\0';
} }
value[len - 1] = '\0';
fw_env_write(name, value); fw_env_write(name, value);

Loading…
Cancel
Save