projects
/
pspp-builds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
str: Make ss_alloc_substring_pool() null-terminate its output.
[pspp-builds.git]
/
src
/
libpspp
/
str.c
diff --git
a/src/libpspp/str.c
b/src/libpspp/str.c
index ba4a26f1426ac51552dd31885d5cdfff5fea321d..08a85ad790f20fe625de485b6c22058226910e2e 100644
(file)
--- a/
src/libpspp/str.c
+++ b/
src/libpspp/str.c
@@
-347,15
+347,16
@@
ss_realloc (struct substring *ss, size_t size)
ss->string = xrealloc (ss->string, size);
}
ss->string = xrealloc (ss->string, size);
}
-/* Makes a pool_alloc_unaligned()'d
copy of the contents of OLD
- in POOL, and stores it in NEW. */
+/* Makes a pool_alloc_unaligned()'d
, null-terminated copy of the contents of
+
OLD
in POOL, and stores it in NEW. */
void
ss_alloc_substring_pool (struct substring *new, struct substring old,
struct pool *pool)
{
void
ss_alloc_substring_pool (struct substring *new, struct substring old,
struct pool *pool)
{
- new->string = pool_alloc_unaligned (pool, old.length);
+ new->string = pool_alloc_unaligned (pool, old.length
+ 1
);
new->length = old.length;
memcpy (new->string, old.string, old.length);
new->length = old.length;
memcpy (new->string, old.string, old.length);
+ new->string[old.length] = '\0';
}
/* Allocates room for a CNT-byte string in NEW in POOL. */
}
/* Allocates room for a CNT-byte string in NEW in POOL. */