Update of /cvsroot/monetdb/pathfinder/compiler/semantics
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv30146/compiler/semantics
Modified Files:
Tag: XQuery_0-22
heuristic.c
Log Message:
Reevaluated the use of (v)snprintf.
On Windows, as on Linux, the size argument is the size of the buffer
to which is printed. The difference between Linux and Windows is that
on Linux if the data doesn't fit, the buffer is still NUL-terminated
(and truncated, obviously), but on Windows the data is truncated but
not NUL-terminated.
The upshot of this is that we can use the correctly-sized buffers, but
we must make sure that truncated buffers are properly NUL-terminated.
Index: heuristic.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/semantics/heuristic.c,v
retrieving revision 1.10
retrieving revision 1.10.6.1
diff -u -d -r1.10 -r1.10.6.1
--- heuristic.c 11 Jan 2008 10:47:16 -0000 1.10
+++ heuristic.c 22 Feb 2008 15:13:17 -0000 1.10.6.1
@@ -285,8 +285,10 @@
if (r) {
r->sem.qname_raw.prefix = "#pf";
r->sem.qname_raw.loc = (char*) PFmalloc(8);
- if (r->sem.qname_raw.loc)
+ if (r->sem.qname_raw.loc) {
snprintf(r->sem.qname_raw.loc, 8, "heur%03d", varnum);
+ r->sem.qname_raw.loc[7] = 0;
+ }
}
return r;
}
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins