Patch: Brian Brooks & Jens Geyer
docstring += '\n';
}
- assert(docstring.length() <= strlen(doctext));
- strcpy(doctext, docstring.c_str());
+ //assert(docstring.length() <= strlen(doctext)); may happen, see THRIFT-1755
+ if(docstring.length() <= strlen(doctext)) {
+ strcpy(doctext, docstring.c_str());
+ } else {
+ free(doctext); // too short
+ doctext = strdup(docstring.c_str());
+ }
return doctext;
}
#pragma GCC diagnostic ignored "-Wunused-function"
#pragma GCC diagnostic ignored "-Wunused-label"
+#include <cassert>
#include <string>
#include <errno.h>
#include <stdlib.h>
if (g_parse_mode == PROGRAM) {
clear_doctext();
g_doctext = strdup(yytext + 3);
- g_doctext[strlen(g_doctext) - 2] = '\0';
+ assert(strlen(g_doctext) >= 2);
+ g_doctext[strlen(g_doctext) - 2] = ' ';
+ g_doctext[strlen(g_doctext) - 1] = '\0';
g_doctext = clean_up_doctext(g_doctext);
g_doctext_lineno = yylineno;
}