Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug report: The Flipper's private variable nV and nC is not copied in the copy function #103

Open
clw-ponyai opened this issue Jun 29, 2020 · 0 comments

Comments

@clw-ponyai
Copy link

When assignment a QProblem to replace another existing one, the Flipper will also be copied:

flipper = rhs.flipper;

But the Flipper's private variable nV and nC is not copied in the copy function, the old value is kept:
return set( &(rhs.bounds),rhs.R, &(rhs.constraints),rhs.Q,rhs.T );

This may leads to buffer overflow. If the old_nV > new_nV, the memcpy will overrun the buffer.
memcpy( R,_R, nV*nV*sizeof(real_t) );

My quick fix for this:

diff -urN a/src/Flipper.cpp b/src/Flipper.cpp
--- a/src/Flipper.cpp	2017-04-03 12:20:42.000000000 +0800
+++ b/src/Flipper.cpp	2020-06-28 12:01:42.438327284 +0800
@@ -238,6 +238,8 @@
 returnValue Flipper::copy(	const Flipper& rhs
 							)
 {
+	nV = rhs.nV;
+	nC = rhs.nC;
 	return set( &(rhs.bounds),rhs.R, &(rhs.constraints),rhs.Q,rhs.T );
 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant