svn commit: samba r21177 - in branches/SAMBA_3_0_25/source/lib:
replace talloc
jra at samba.org
jra at samba.org
Tue Feb 6 06:32:55 GMT 2007
Author: jra
Date: 2007-02-06 06:32:54 +0000 (Tue, 06 Feb 2007)
New Revision: 21177
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=21177
Log:
Merge from SAMBA_3_0.
merged va_end() changes from Samba4
Jeremy.
Modified:
branches/SAMBA_3_0_25/source/lib/replace/snprintf.c
branches/SAMBA_3_0_25/source/lib/talloc/talloc.c
Changeset:
Modified: branches/SAMBA_3_0_25/source/lib/replace/snprintf.c
===================================================================
--- branches/SAMBA_3_0_25/source/lib/replace/snprintf.c 2007-02-06 05:58:35 UTC (rev 21176)
+++ branches/SAMBA_3_0_25/source/lib/replace/snprintf.c 2007-02-06 06:32:54 UTC (rev 21177)
@@ -742,6 +742,8 @@
ret = currlen;
done:
+ va_end(args);
+
while (chunks) {
cnk = chunks->next;
free(chunks);
@@ -1260,16 +1262,16 @@
va_list ap2;
VA_COPY(ap2, ap);
-
ret = vsnprintf(NULL, 0, format, ap2);
+ va_end(ap2);
if (ret <= 0) return ret;
(*ptr) = (char *)malloc(ret+1);
if (!*ptr) return -1;
VA_COPY(ap2, ap);
-
ret = vsnprintf(*ptr, ret+1, format, ap2);
+ va_end(ap2);
return ret;
}
Modified: branches/SAMBA_3_0_25/source/lib/talloc/talloc.c
===================================================================
--- branches/SAMBA_3_0_25/source/lib/talloc/talloc.c 2007-02-06 05:58:35 UTC (rev 21176)
+++ branches/SAMBA_3_0_25/source/lib/talloc/talloc.c 2007-02-06 06:32:54 UTC (rev 21177)
@@ -1174,10 +1174,11 @@
va_list ap2;
char c;
+ /* this call looks strange, but it makes it work on older solaris boxes */
va_copy(ap2, ap);
-
- /* this call looks strange, but it makes it work on older solaris boxes */
- if ((len = vsnprintf(&c, 1, fmt, ap2)) < 0) {
+ len = vsnprintf(&c, 1, fmt, ap2);
+ va_end(ap2);
+ if (len < 0) {
return NULL;
}
@@ -1185,6 +1186,7 @@
if (ret) {
va_copy(ap2, ap);
vsnprintf(ret, len+1, fmt, ap2);
+ va_end(ap2);
_talloc_set_name_const(ret, ret);
}
@@ -1226,10 +1228,13 @@
tc = talloc_chunk_from_ptr(s);
+ s_len = tc->size - 1;
+
va_copy(ap2, ap);
+ len = vsnprintf(&c, 1, fmt, ap2);
+ va_end(ap2);
- s_len = tc->size - 1;
- if ((len = vsnprintf(&c, 1, fmt, ap2)) <= 0) {
+ if (len <= 0) {
/* Either the vsnprintf failed or the format resulted in
* no characters being formatted. In the former case, we
* ought to return NULL, in the latter we ought to return
@@ -1243,8 +1248,8 @@
if (!s) return NULL;
va_copy(ap2, ap);
-
vsnprintf(s+s_len, len+1, fmt, ap2);
+ va_end(ap2);
_talloc_set_name_const(s, s);
return s;
More information about the samba-cvs
mailing list