THRIFT-1755 Comment parsing bug
Patch: Brian Brooks & Jens Geyer
diff --git a/compiler/cpp/src/main.cc b/compiler/cpp/src/main.cc
index 0cefa7e..54c23f5 100755
--- a/compiler/cpp/src/main.cc
+++ b/compiler/cpp/src/main.cc
@@ -517,8 +517,13 @@
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;
}