Closed ghost closed 4 years ago
I found the issue - i replaced the '0' at the end of the call with 'NULL' and it worked. I thought NULL was defined as 0 so I really don't get why this matters, but problem solved!
Thought I'd actually explain this because it'll catch you elsewhere too.
Anywhere you're using variable arguments (functions that have "..."), the variable number of arguments must have an explicitly stated type. Or really, width in bytes. Because the function implementing the function is going to step through the arguments byte by byte. So if you have foo(...) where the variable list should be integers, foo(int, int, int) is implementede to look at the first sizeof(int), then the next, etc.
So if foo(...) is stated to accept pointers with NULL as the last pointer, passing 0 is incorrect. The reason being that the zero may be (for instance) an integer (32 bits) while the pointer may be 64 bits. That means that instead of a NULL, you're really passing a zero plus whatever comes for the next 32 bits. If your integer length is the same as your pointer length, it's correct but cause you got lucky.
The only function I can think of in the wild where this is important is execlp(3) and friends, where the arguments must be terminated by a NULL pointer. Same caveat there if you pass a zero.
That makes sense. Thanks for the explanation!
I am running kcgi 0.10.11 installed from package on openbsd. I've been using the khtml functions for years but recently took a look at the kxml functions to try to create an svg image. I hit a snag when trying to add multiple attributes to the root element.
Here is the setup:
where resp_open() does this:
The above code will produce this:
<?xml version="1.0" encoding="utf-8" ?><svg xmlns="http://www.w3.org/2000/svg"></svg>
Okay, so far so good, but if I uncomment a line to add another attribute, kxml_pushattrs() does not return and the resulting page is solid white. I did some searching for examples of this in use and found kcaldav, but from what I can see, I am doing the same thing.
If you can see what dumb mistake I am probably making, please let me know. If not, what else can I do to track down this issue?
Thanks!