]> 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 7c837484c705239f06537e2781209b396c1ef4ba..a2cd7a3f772743c7fe9ac06fde3042fd6ab28d98 100644 (file)
@@ -1,18 +1,12 @@
-/* $Id$
-
-This file is part of libmspcore
-Copyright © 2008-2009  Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
 #include <cstdlib>
 #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"
@@ -67,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)
                        {
@@ -97,6 +91,7 @@ TimeZone get_local_timezone()
 
                                name = ptr+abbrind;
                        }
+                       delete[] buf;
                }
                close(fd);