- char tmpbuf[cumLength];
- unsigned int bufpos = 0;
- for(int i=0; i<word; ++i) {
- /*
- * Sanity check for corrupt/mismatched sound data input - avoids a seg fault
- * (As long as the calling function checks the return value!!)
- * This check should be left in even when the default Flightgear files are known
- * to be OK since it checks for mis-indexing of voice files by 3rd party developers.
- */
- if((wdptr[i].offset + wdptr[i].length) > rawDataSize) {
- SG_LOG(SG_ATC, SG_ALERT, "ERROR - mismatch between ATC .wav and .vce file in ATCVoice.cxx\n");
- SG_LOG(SG_ATC, SG_ALERT, "Offset + length: " << wdptr[i].offset + wdptr[i].length
- << " exceeds rawdata size: " << rawDataSize << endl);
-
- dataOK = false;
- return "";
- }
- memcpy(tmpbuf + bufpos, rawSoundData + wdptr[i].offset, wdptr[i].length);
- bufpos += wdptr[i].length;
+ char* data = (char*)malloc(*len);
+ if (data == 0) {
+ SG_LOG(SG_ATC, SG_ALERT, "ERROR - could not allocate " << *len << " bytes of memory for ATIS sound\n");
+ *len = 0;
+ return 0;