* src/buf.c: applied patch from Masayuki Sunou fixing a loop

due to an error in growing buffers.
Daniel
This commit is contained in:
Daniel Veillard 2007-08-30 13:12:44 +00:00
parent b001650c7d
commit 3c999f7ff4
2 changed files with 11 additions and 4 deletions

View File

@ -1,3 +1,8 @@
Thu Aug 30 15:11:44 CEST 2007 Daniel Veillard <veillard@redhat.com>
* src/buf.c: applied patch from Masayuki Sunou fixing a loop
due to an error in growing buffers.
Wed Aug 29 14:43:00 BST 2007 Richard W.M. Jones <rjones@redhat.com>
* src/xen_internal.c (xenHypervisorDomainInterfaceStats): Swap

View File

@ -159,7 +159,7 @@ virBufferContentAndFree (virBufferPtr buf)
int
virBufferVSprintf(virBufferPtr buf, const char *format, ...)
{
int size, count;
int size, count, grow_size;
va_list locarg, argptr;
if ((format == NULL) || (buf == NULL)) {
@ -172,7 +172,8 @@ virBufferVSprintf(virBufferPtr buf, const char *format, ...)
locarg)) < 0) || (count >= size - 1)) {
buf->content[buf->use] = 0;
va_end(locarg);
if (virBufferGrow(buf, 1000) < 0) {
grow_size = (count > 1000) ? count : 1000;
if (virBufferGrow(buf, grow_size) < 0) {
return (-1);
}
size = buf->size - buf->use - 1;
@ -198,7 +199,7 @@ virBufferVSprintf(virBufferPtr buf, const char *format, ...)
int
virBufferEscapeString(virBufferPtr buf, const char *format, const char *str)
{
int size, count, len;
int size, count, len, grow_size;
char *escaped, *out;
const char *cur;
@ -248,7 +249,8 @@ virBufferEscapeString(virBufferPtr buf, const char *format, const char *str)
while (((count = snprintf(&buf->content[buf->use], size, format,
(char *)escaped)) < 0) || (count >= size - 1)) {
buf->content[buf->use] = 0;
if (virBufferGrow(buf, 1000) < 0) {
grow_size = (count > 1000) ? count : 1000;
if (virBufferGrow(buf, grow_size) < 0) {
free(escaped);
return (-1);
}