From cbd1017a952ea18826fed6c70c9290f050e1f9f6 Mon Sep 17 00:00:00 2001 From: Markus Rosenstihl Date: Tue, 17 Nov 2015 16:34:32 +0000 Subject: [PATCH] fixed nasty bug leading to segfault with --no-omit-frame-pointer compile option in write_adcdata_base64 --- core/xml_result.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/core/xml_result.cpp b/core/xml_result.cpp index e9f63a6..aaf98ab 100644 --- a/core/xml_result.cpp +++ b/core/xml_result.cpp @@ -475,8 +475,8 @@ int xml_result_writer::write_configuration_results_to_file(const std::string& fi FILE* out=fopen(filename.c_str(),"w"); fprintf(out,"\n"); fprintf(out,"\n\n",ress.job_no); - XMLCh tempStr[100]; - xercesc::XMLString::transcode("LS", tempStr, 99); + XMLCh tempStr[300]; + xercesc::XMLString::transcode("LS", tempStr, 299); xercesc::DOMImplementation *impl2 = xercesc::DOMImplementationRegistry::getDOMImplementation(tempStr); xercesc::DOMLSSerializer *theSerializer=(static_cast(impl2))->createLSSerializer(); xercesc::DOMLSOutput *theOutputDesc=(static_cast(impl2))->createLSOutput(); @@ -548,9 +548,9 @@ int xml_result_writer::write_adc_to_file(const std::string& filename, const adc_ // fall back to some default mode data_save_mode_type how=data_save_mode; if (how==defaultmode) how=ascii; - FILE* out=fopen(filename.c_str(),"w"); + FILE* out=fopen(const_cast(filename.c_str()),"w"); if (out==0) { - fprintf(stderr,"could not open file %s\n",filename.c_str()); + fprintf(stderr,"write_adc_to_file: could not open file %s\n",filename.c_str()); return 0; } fprintf(out,"\n"); @@ -603,9 +603,9 @@ int xml_result_writer::write_adcdata_separate(FILE* out, const std::string& data int xml_result_writer::write_adcdata_formated(FILE* out, const std::string& format, const adc_result* res) const { fprintf(out,"\n",res->samples,res->sampling_frequency, res->nchannels); for(size_t i=0;isamples;++i) { - for (int j = 0; j < res->nchannels; j++) { - fprintf(out, format.c_str(), res->data[i*2 + j]); - } + for(int j=0;jnchannels;++j) { + fprintf(out, format.c_str(), res->data[i*2+ j]); + } } fprintf(out,"\n"); return 0; @@ -616,7 +616,7 @@ int xml_result_writer::write_adcdata_base64(FILE* out, const adc_result* res) co unsigned int base64length=0; XMLByte* base64buffer=xercesc::Base64::encode( reinterpret_cast(res->data),res->samples*res->nchannels*sizeof(short int),reinterpret_cast(&base64length)); fwrite(base64buffer,1,base64length,out); - xercesc::XMLString::release(reinterpret_cast(&base64buffer)); + delete(base64buffer); fprintf(out,"\n"); return 0; }