projects
/
oweals
/
u-boot.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
arm: socfpga: cyclone5_socdk: Enable qspiload console command
[oweals/u-boot.git]
/
lib
/
hashtable.c
diff --git
a/lib/hashtable.c
b/lib/hashtable.c
index 18ed5901ec284b63150435bf5af9b8db6b42d373..02b41050a44f6656e9605e288f5f6a97faf3539c 100644
(file)
--- a/
lib/hashtable.c
+++ b/
lib/hashtable.c
@@
-789,12
+789,13
@@
int himport_r(struct hsearch_data *htab,
}
/* we allocate new space to make sure we can write to the array */
}
/* we allocate new space to make sure we can write to the array */
- if ((data = malloc(size)) == NULL) {
- debug("himport_r: can't malloc %zu bytes\n", size);
+ if ((data = malloc(size
+ 1
)) == NULL) {
+ debug("himport_r: can't malloc %zu bytes\n", size
+ 1
);
__set_errno(ENOMEM);
return 0;
}
memcpy(data, env, size);
__set_errno(ENOMEM);
return 0;
}
memcpy(data, env, size);
+ data[size] = '\0';
dp = data;
/* make a local copy of the list of variables */
dp = data;
/* make a local copy of the list of variables */
@@
-841,8
+842,10
@@
int himport_r(struct hsearch_data *htab,
}
}
}
}
- if(!size)
+ if (!size) {
+ free(data);
return 1; /* everything OK */
return 1; /* everything OK */
+ }
if(crlf_is_lf) {
/* Remove Carriage Returns in front of Line Feeds */
unsigned ignored_crs = 0;
if(crlf_is_lf) {
/* Remove Carriage Returns in front of Line Feeds */
unsigned ignored_crs = 0;
@@
-906,6
+909,7
@@
int himport_r(struct hsearch_data *htab,
if (*name == 0) {
debug("INSERT: unable to use an empty key\n");
__set_errno(EINVAL);
if (*name == 0) {
debug("INSERT: unable to use an empty key\n");
__set_errno(EINVAL);
+ free(data);
return 0;
}
return 0;
}