Mercurial > hg > octave-avbm
changeset 13876:c1b072ef1fc7
avoid writing outside bounds of matrix
* graphics.cc (convert_text_position): Resize retval for each case.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 17 Nov 2011 05:21:16 -0500 |
parents | c1b754d93572 |
children | 0d32a681d943 |
files | src/graphics.cc |
diffstat | 1 files changed, 9 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/graphics.cc +++ b/src/graphics.cc @@ -564,7 +564,7 @@ graphics_object go = gh_manager::get_object (props.get___myhandle__ ()); graphics_object ax = go.get_ancestor ("axes"); - Matrix retval (1, pos.numel (), 0); + Matrix retval; if (ax.valid_object ()) { @@ -583,6 +583,8 @@ v2 = ax_xform.transform (pos(0) + pos(2), pos(1) + pos(3), 0); + retval.resize (1, 4); + retval(0) = v1(0) - ax_bbox(0) + 1; retval(1) = ax_bbox(1) + ax_bbox(3) - v1(1) + 1; retval(2) = v2(0) - v1(0); @@ -592,6 +594,8 @@ { ColumnVector v = ax_xform.transform (pos(0), pos(1), pos(2)); + retval.resize (1, 3); + retval(0) = v(0) - ax_bbox(0) + 1; retval(1) = ax_bbox(1) + ax_bbox(3) - v(1) + 1; retval(2) = 0; @@ -611,6 +615,8 @@ v2 = ax_xform.untransform (retval(0) + retval(2) + ax_bbox(0) - 1, ax_bbox(1) + ax_bbox(3) - (retval(1) + retval(3)) + 1); + retval.resize (1, 4); + retval(0) = v1(0); retval(1) = v1(1); retval(2) = v2(0) - v1(0); @@ -621,6 +627,8 @@ ColumnVector v = ax_xform.untransform (retval(0) + ax_bbox(0) - 1, ax_bbox(1) + ax_bbox(3) - retval(1) + 1); + retval.resize (1, 3); + retval(0) = v(0); retval(1) = v(1); retval(2) = v(2);