diff -up libqalculate-0.9.7/libqalculate/util.cc.buffer libqalculate-0.9.7/libqalculate/util.cc --- libqalculate-0.9.7/libqalculate/util.cc.buffer 2009-12-02 21:24:27.000000000 +0100 +++ libqalculate-0.9.7/libqalculate/util.cc 2016-04-25 13:41:49.889530190 +0200 @@ -26,8 +26,6 @@ bool eqstr::operator()(const char *s1, c return strcmp(s1, s2) == 0; } -char buffer[20000]; - string date2s(int year, int month, int day) { string str = i2s(year); str += "-"; @@ -522,36 +520,54 @@ string& remove_parenthesis(string &str) string d2s(double value, int precision) { // qgcvt(value, precision, buffer); - sprintf(buffer, "%.*G", precision, value); + char *buffer = NULL; + if (asprintf(&buffer, "%.*G", precision, value) == -1) + exit(EXIT_FAILURE); string stmp = buffer; + free(buffer); // gsub("e", "E", stmp); return stmp; } string p2s(void *o) { - sprintf(buffer, "%p", o); + char *buffer = NULL; + if (asprintf(&buffer, "%p", o) == -1) + exit(EXIT_FAILURE); string stmp = buffer; + free(buffer); return stmp; } string i2s(int value) { // char buffer[10]; - sprintf(buffer, "%i", value); + char *buffer = NULL; + if (asprintf(&buffer, "%i", value) == -1) + exit(EXIT_FAILURE); string stmp = buffer; + free(buffer); return stmp; } string i2s(long int value) { - sprintf(buffer, "%li", value); + char *buffer = NULL; + if (asprintf(&buffer, "%li", value) == -1) + exit(EXIT_FAILURE); string stmp = buffer; + free(buffer); return stmp; } string i2s(unsigned int value) { - sprintf(buffer, "%u", value); + char *buffer = NULL; + if (asprintf(&buffer, "%u", value) == -1) + exit(EXIT_FAILURE); string stmp = buffer; + free(buffer); return stmp; } string i2s(unsigned long int value) { - sprintf(buffer, "%lu", value); + char *buffer = NULL; + if (asprintf(&buffer, "%lu", value) == -1) + exit(EXIT_FAILURE); string stmp = buffer; + free(buffer); return stmp; } const char *b2yn(bool b, bool capital) {