]> git.tdb.fi Git - libs/core.git/blobdiff - source/time/timezone.cpp
Variable length arrays on stack are not valid C++
[libs/core.git] / source / time / timezone.cpp
index 56fcf8f588a389325a1fda85cec2577b82b1c54d..a2cd7a3f772743c7fe9ac06fde3042fd6ab28d98 100644 (file)
@@ -2,10 +2,11 @@
 #ifdef WIN32
 #include <windows.h>
 #else
+#include <unistd.h>
 #include <fcntl.h>
 #endif
-#include <msp/core/systemerror.h>
 #include <msp/strings/format.h>
+#include <msp/core/systemerror.h>
 #include "timestamp.h"
 #include "timezone.h"
 #include "units.h"
@@ -60,7 +61,7 @@ TimeZone get_local_timezone()
                        long typecnt = get_long(ptr);
                        long charcnt = get_long(ptr);
                        int size = timecnt*5+typecnt*6+isgmtcnt+isstdcnt+leapcnt*8+charcnt;
-                       char buf[size];
+                       char *buf = new char[size];
                        len = read(fd, buf, size);
                        if(len==size)
                        {
@@ -90,6 +91,7 @@ TimeZone get_local_timezone()
 
                                name = ptr+abbrind;
                        }
+                       delete[] buf;
                }
                close(fd);