Skip to content

Commit

Permalink
Add bounds check to all format options in enable_stream
Browse files Browse the repository at this point in the history
  • Loading branch information
Lior Ramati committed Jan 16, 2019
1 parent a691401 commit 7372e4c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions wrappers/matlab/config.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ function enable_stream(this, varargin)
which = 'enable_stream#stream';
case 3
if isa(varargin{2}, 'realsense.format')
validateattributes(varargin{2}, {'realsense.format'}, {'scalar'}, '', 'format', 3);
validateattributes(varargin{2}, {'realsense.format', 'numeric'}, {'scalar', 'nonnegative', 'real', 'integer', '<=', int64(realsense.format.count)}, '', 'format', 3);
which = 'enable_stream#format';
else
validateattributes(varargin{2}, {'numeric'}, {'scalar', 'real', 'integer'}, '', 'stream_index', 3);
which = 'enable_stream#stream';
end
case 4
if isa(varargin{2}, 'realsense.format')
validateattributes(varargin{2}, {'realsense.format'}, {'scalar'}, '', 'format', 3);
validateattributes(varargin{2}, {'realsense.format', 'numeric'}, {'scalar', 'nonnegative', 'real', 'integer', '<=', int64(realsense.format.count)}, '', 'format', 3);
validateattributes(varargin{3}, {'numeric'}, {'scalar', 'nonnegative', 'real', 'integer'}, '', 'framerate', 4);
which = 'enable_stream#format';
elseif isa(varargin{3}, 'realsense.format')
validateattributes(varargin{2}, {'numeric'}, {'scalar', 'real', 'integer'}, '', 'stream_index', 3);
validateattributes(varargin{3}, {'realsense.format'}, {'scalar'}, '', 'format', 4);
validateattributes(varargin{3}, {'realsense.format', 'numeric'}, {'scalar', 'nonnegative', 'real', 'integer', '<=', int64(realsense.format.count)}, '', 'format', 4);
which = 'enable_stream#extended';
else
validateattributes(varargin{2}, {'numeric'}, {'scalar', 'nonnegative', 'real', 'integer'}, '', 'width', 3);
Expand All @@ -48,13 +48,13 @@ function enable_stream(this, varargin)
case 5
if isa(varargin{3}, 'realsense.format')
validateattributes(varargin{2}, {'numeric'}, {'scalar', 'real', 'integer'}, '', 'stream_index', 3);
validateattributes(varargin{3}, {'realsense.format'}, {'scalar'}, '', 'format', 4);
validateattributes(varargin{3}, {'realsense.format', 'numeric'}, {'scalar', 'nonnegative', 'real', 'integer', '<=', int64(realsense.format.count)}, '', 'format', 4);
validateattributes(varargin{4}, {'numeric'}, {'scalar', 'nonnegative', 'real', 'integer'}, '', 'framerate', 5);
which = 'enable_stream#extended';
elseif isa(varargin{4}, 'realsense.format')
validateattributes(varargin{2}, {'numeric'}, {'scalar', 'nonnegative', 'real', 'integer'}, '', 'width', 3);
validateattributes(varargin{3}, {'numeric'}, {'scalar', 'nonnegative', 'real', 'integer'}, '', 'height', 4);
validateattributes(varargin{4}, {'realsense.format'}, {'scalar'}, '', 'format', 5);
validateattributes(varargin{4}, {'realsense.format', 'numeric'}, {'scalar', 'nonnegative', 'real', 'integer', '<=', int64(realsense.format.count)}, '', 'format', 5);
which = 'enable_stream#size';
else
validateattributes(varargin{2}, {'numeric'}, {'scalar', 'real', 'integer'}, '', 'stream_index', 3);
Expand All @@ -66,7 +66,7 @@ function enable_stream(this, varargin)
if isa(varargin{4}, 'realsense.format')
validateattributes(varargin{2}, {'numeric'}, {'scalar', 'nonnegative', 'real', 'integer'}, '', 'width', 3);
validateattributes(varargin{3}, {'numeric'}, {'scalar', 'nonnegative', 'real', 'integer'}, '', 'height', 4);
validateattributes(varargin{4}, {'realsense.format'}, {'scalar'}, '', 'format', 5);
validateattributes(varargin{4}, {'realsense.format', 'numeric'}, {'scalar', 'nonnegative', 'real', 'integer', '<=', int64(realsense.format.count)}, '', 'format', 5);
validateattributes(varargin{5}, {'numeric'}, {'scalar', 'nonnegative', 'real', 'integer'}, '', 'framerate', 6);
which = 'enable_stream#size';
else
Expand Down

0 comments on commit 7372e4c

Please sign in to comment.