aboutsummaryrefslogtreecommitdiffstats
path: root/lib/wx/c_src
diff options
context:
space:
mode:
authorDan Gudmundsson <[email protected]>2015-05-19 10:01:42 +0200
committerDan Gudmundsson <[email protected]>2015-06-01 13:07:32 +0200
commit5b2ad02d50a23b5e82f9ebbc644622e42199ea95 (patch)
treefead9dbe4e5365808940e3e301c76745e4f976da /lib/wx/c_src
parent8260f916c2ab9b9dff9752b47e47d07ac3d95c92 (diff)
downloadotp-5b2ad02d50a23b5e82f9ebbc644622e42199ea95.tar.gz
otp-5b2ad02d50a23b5e82f9ebbc644622e42199ea95.tar.bz2
otp-5b2ad02d50a23b5e82f9ebbc644622e42199ea95.zip
wx: Fix bad float in return values
To many floats in return value could cause a reallocation and pointers to reallocated data. Fix it by ensuring that the temp float array is large enough before add values to it.
Diffstat (limited to 'lib/wx/c_src')
-rw-r--r--lib/wx/c_src/gen/wxe_funcs.cpp6
-rw-r--r--lib/wx/c_src/wxe_return.cpp9
-rw-r--r--lib/wx/c_src/wxe_return.h2
3 files changed, 16 insertions, 1 deletions
diff --git a/lib/wx/c_src/gen/wxe_funcs.cpp b/lib/wx/c_src/gen/wxe_funcs.cpp
index 3b11c0642e..dca0f74dcd 100644
--- a/lib/wx/c_src/gen/wxe_funcs.cpp
+++ b/lib/wx/c_src/gen/wxe_funcs.cpp
@@ -5533,6 +5533,7 @@ case wxDC_GetUserScale: { // wxDC::GetUserScale
wxDC *This = (wxDC *) getPtr(bp,memenv); bp += 4;
if(!This) throw wxe_badarg(0);
This->GetUserScale(&x,&y);
+ rt.ensureFloatCount(3);
rt.addFloat(x);
rt.addFloat(y);
rt.addTupleCount(2);
@@ -6430,6 +6431,7 @@ case wxGraphicsContext_GetTextExtent: { // wxGraphicsContext::GetTextExtent
bp += *textLen+((8-((0+ *textLen) & 7)) & 7);
if(!This) throw wxe_badarg(0);
This->GetTextExtent(text,&width,&height,&descent,&externalLeading);
+ rt.ensureFloatCount(5);
rt.addFloat(width);
rt.addFloat(height);
rt.addFloat(descent);
@@ -6575,6 +6577,7 @@ case wxGraphicsMatrix_Get: { // wxGraphicsMatrix::Get
wxGraphicsMatrix *This = (wxGraphicsMatrix *) getPtr(bp,memenv); bp += 4;
if(!This) throw wxe_badarg(0);
This->Get(&a,&b,&c,&d,&tx,&ty);
+ rt.ensureFloatCount(7);
rt.addFloat(a);
rt.addFloat(b);
rt.addFloat(c);
@@ -6676,6 +6679,7 @@ case wxGraphicsMatrix_TransformPoint: { // wxGraphicsMatrix::TransformPoint
wxGraphicsMatrix *This = (wxGraphicsMatrix *) getPtr(bp,memenv); bp += 4;
if(!This) throw wxe_badarg(0);
This->TransformPoint(&x,&y);
+ rt.ensureFloatCount(3);
rt.addFloat(x);
rt.addFloat(y);
rt.addTupleCount(2);
@@ -6687,6 +6691,7 @@ case wxGraphicsMatrix_TransformDistance: { // wxGraphicsMatrix::TransformDistanc
wxGraphicsMatrix *This = (wxGraphicsMatrix *) getPtr(bp,memenv); bp += 4;
if(!This) throw wxe_badarg(0);
This->TransformDistance(&dx,&dy);
+ rt.ensureFloatCount(3);
rt.addFloat(dx);
rt.addFloat(dy);
rt.addTupleCount(2);
@@ -23746,6 +23751,7 @@ case wxAuiManager_GetDockSizeConstraint: { // wxAuiManager::GetDockSizeConstrain
wxAuiManager *This = (wxAuiManager *) getPtr(bp,memenv); bp += 4;
if(!This) throw wxe_badarg(0);
This->GetDockSizeConstraint(&width_pct,&height_pct);
+ rt.ensureFloatCount(3);
rt.addFloat(width_pct);
rt.addFloat(height_pct);
rt.addTupleCount(2);
diff --git a/lib/wx/c_src/wxe_return.cpp b/lib/wx/c_src/wxe_return.cpp
index aebf6bae1b..accd818a14 100644
--- a/lib/wx/c_src/wxe_return.cpp
+++ b/lib/wx/c_src/wxe_return.cpp
@@ -84,7 +84,13 @@ INLINE
unsigned int wxeReturn::size() {
return rt.GetCount();
}
-
+
+
+INLINE
+void wxeReturn::ensureFloatCount(size_t n) {
+ temp_float.Alloc(n);
+}
+
INLINE
void wxeReturn::add(ErlDrvTermData type, ErlDrvTermData data) {
rt.Add(type);
@@ -222,6 +228,7 @@ INLINE
void wxeReturn::add(wxArrayDouble val) {
unsigned int len = val.GetCount();
+ temp_float.Alloc(len);
for (unsigned int i = 0; i< len; i++) {
addFloat(val[i]);
}
diff --git a/lib/wx/c_src/wxe_return.h b/lib/wx/c_src/wxe_return.h
index 80946e2dc6..a157348f1d 100644
--- a/lib/wx/c_src/wxe_return.h
+++ b/lib/wx/c_src/wxe_return.h
@@ -116,6 +116,8 @@ public:
void add(const wxHtmlLinkInfo &val);
+ void ensureFloatCount(size_t n);
+
int send();
void reset();