Skip to content

Commit

Permalink
Merge pull request #25420 from Dr15Jones/fixFWLiteTempStringUse_9_4
Browse files Browse the repository at this point in the history
Do not hold on to empty strings passed to getByLabel [9_4]
  • Loading branch information
cmsbuild committed Dec 6, 2018
2 parents 182d723 + 7f2c51c commit fca19b8
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions DataFormats/FWLite/src/DataGetterHelper.cc
Expand Up @@ -44,6 +44,7 @@ namespace fwlite {
//
// empty object used to signal that the branch requested was not found
static internal::Data branchNotFound;
static char kEmptyString[1] = {0};

//
// constructors and destructor
Expand Down Expand Up @@ -218,16 +219,16 @@ namespace fwlite {
std::strncpy(newModule,iModuleLabel,moduleLabelLen);
labels_.push_back(newModule);

char* newProduct = const_cast<char*>(key.product());
if(newProduct[0] != 0) {
size_t newProductLen = strlen(newProduct)+1;
char* newProduct = kEmptyString;
if(key.product()[0] != 0) {
size_t newProductLen = strlen(key.product())+1;
newProduct = new char[newProductLen];
std::strncpy(newProduct,key.product(),newProductLen);
labels_.push_back(newProduct);
}
char* newProcess = const_cast<char*>(key.process());
if(newProcess[0]!=0) {
size_t newProcessLen = strlen(newProcess)+1;
char* newProcess = kEmptyString;
if(key.process()[0]!=0) {
size_t newProcessLen = strlen(key.process())+1;
newProcess = new char[newProcessLen];
std::strncpy(newProcess,key.process(),newProcessLen);
labels_.push_back(newProcess);
Expand Down

0 comments on commit fca19b8

Please sign in to comment.