fixed nasty bug leading to segfault with --no-omit-frame-pointer compile option in write_adcdata_base64

This commit is contained in:
Markus Rosenstihl 2015-11-17 16:34:32 +00:00
parent 505c6ca44d
commit cbd1017a95

View File

@ -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,"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n");
fprintf(out,"<result job=\"%" SIZETPRINTFLETTER "\">\n<configuration>\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<xercesc::DOMImplementationLS*>(impl2))->createLSSerializer();
xercesc::DOMLSOutput *theOutputDesc=(static_cast<xercesc::DOMImplementationLS*>(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<char*>(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,"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\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,"<adcdata samples=\"%" SIZETPRINTFLETTER "\" rate=\"%g\" channels=\"%i\">\n",res->samples,res->sampling_frequency, res->nchannels);
for(size_t i=0;i<res->samples;++i) {
for (int j = 0; j < res->nchannels; j++) {
fprintf(out, format.c_str(), res->data[i*2 + j]);
}
for(int j=0;j<res->nchannels;++j) {
fprintf(out, format.c_str(), res->data[i*2+ j]);
}
}
fprintf(out,"</adcdata>\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<XMLByte*>(res->data),res->samples*res->nchannels*sizeof(short int),reinterpret_cast<XMLSize_t*>(&base64length));
fwrite(base64buffer,1,base64length,out);
xercesc::XMLString::release(reinterpret_cast<char**>(&base64buffer));
delete(base64buffer);
fprintf(out,"</adcdata>\n");
return 0;
}