pjpidf_print() does not return < 0 if there is not enough
room for the document to be printed. Rather, it returns
39, the length of the XML prolog.
The algorithm also had a bug in that it would return if
it attempted to grow the string larger.
........
Merged revisions 416442 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@416444
65c4cc65-6c06-0410-ace0-
fbb531ad65f3
}
#define MAX_STRING_GROWTHS 3
+#define XML_PROLOG 39
static void pidf_to_string(void *body, struct ast_str **str)
{
do {
size = pjpidf_print(pres, ast_str_buffer(*str), ast_str_size(*str) - 1);
- if (size < 0) {
+ if (size == XML_PROLOG) {
ast_str_make_space(str, ast_str_size(*str) * 2);
++growths;
- return;
}
- } while (size < 0 && growths < MAX_STRING_GROWTHS);
+ } while (size == XML_PROLOG && growths < MAX_STRING_GROWTHS);
- if (size < 0) {
+ if (size == XML_PROLOG) {
ast_log(LOG_WARNING, "PIDF body text too large\n");
return;
}
}
#define MAX_STRING_GROWTHS 3
+#define XML_PROLOG 39
static void xpidf_to_string(void *body, struct ast_str **str)
{
int size;
do {
-
size = pjxpidf_print(pres, ast_str_buffer(*str), ast_str_size(*str));
- if (size < 0) {
+ if (size == XML_PROLOG) {
ast_str_make_space(str, ast_str_size(*str) * 2);
++growths;
- return;
}
- } while (size < 0 && growths < MAX_STRING_GROWTHS);
+ } while (size == XML_PROLOG && growths < MAX_STRING_GROWTHS);
- if (size < 0) {
+ if (size == XML_PROLOG) {
ast_log(LOG_WARNING, "XPIDF body text too large\n");
return;
}