+#include <string.h> // strncpy()
+
#include <Main/globals.hxx>
#include <Airports/simple.hxx>
_content = new char *[_nAirports+1];
for (int i = 0; i < _nAirports; i++) {
const FGAirport * airport = _airports->getAirport(i);
- snprintf(buf, 1023, "%s %s\n",
+ snprintf(buf, 1023, "%s %s\0",
airport->id.c_str(),
airport->name.c_str());
- _content[i] = strndup(buf, 1023);
+
+ unsigned int buf_len = (strlen(buf) > 1023) ? 1023 : strlen(buf);
+
+ _content[i] = new char[buf_len+1];
+ memcpy(_content[i], buf, buf_len);
+ _content[i][buf_len+1] = '\0';
}
_content[_nAirports] = 0;
newList(_content);