Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mantid
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mantidproject
mantid
Commits
a45a400b
Commit
a45a400b
authored
14 years ago
by
Peterson, Peter
Browse files
Options
Downloads
Patches
Plain Diff
Check for the pixel id going out of bounds. Fixes #1460.
parent
bd84bb78
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Code/Mantid/DataHandling/src/LoadEventPreNeXus.cpp
+18
-5
18 additions, 5 deletions
Code/Mantid/DataHandling/src/LoadEventPreNeXus.cpp
with
18 additions
and
5 deletions
Code/Mantid/DataHandling/src/LoadEventPreNeXus.cpp
+
18
−
5
View file @
a45a400b
#include
<algorithm>
#include
<sstream>
#include
<stdexcept>
#include
<functional>
#include
<iostream>
#include
<vector>
#include
"MantidDataHandling/LoadEventPreNeXus.h"
...
...
@@ -574,11 +576,6 @@ void LoadEventPreNeXus::procEventsParallel(DataObjects::EventWorkspace_sptr & wo
}
static
std
::
time_t
to_time_t
(
ptime
t
)
{
if
(
t
.
is_special
())
...
...
@@ -697,16 +694,24 @@ void LoadEventPreNeXus::loadPixelMap(const std::string &filename)
ifstream
*
handle
=
new
ifstream
(
filename
.
c_str
(),
std
::
ios
::
binary
);
size_t
file_size
=
getFileSize
<
PixelType
>
(
handle
);
PixelType
max_pid
=
static_cast
<
PixelType
>
(
file_size
);
//std::cout << "file is " << file_size << std::endl;
size_t
offset
=
0
;
size_t
buffer_size
=
getBufferSize
(
file_size
);
PixelType
*
buffer
=
new
PixelType
[
buffer_size
];
size_t
obj_size
=
sizeof
(
PixelType
);
bool
success
=
true
;
// see if something wierd went on
while
(
offset
<
file_size
)
{
// read a section and put it into the object
handle
->
read
(
reinterpret_cast
<
char
*>
(
buffer
),
buffer_size
*
obj_size
);
if
(
std
::
find_if
(
buffer
,
(
buffer
+
buffer_size
),
std
::
bind2nd
(
std
::
greater
<
PixelType
>
(),
file_size
))
!=
(
buffer
+
buffer_size
))
{
success
=
false
;
break
;
}
this
->
pixelmap
.
insert
(
this
->
pixelmap
.
end
(),
buffer
,
(
buffer
+
buffer_size
));
offset
+=
buffer_size
;
...
...
@@ -725,6 +730,14 @@ void LoadEventPreNeXus::loadPixelMap(const std::string &filename)
handle
->
close
();
delete
handle
;
if
(
!
success
)
{
this
->
g_log
.
warning
(
"Pixel id in mapping file was out of bounds. Loading without mapping file"
);
this
->
numpixel
=
0
;
this
->
pixelmap
.
clear
();
this
->
using_mapping_file
=
false
;
}
//If we got here, the mapping file was loaded correctly and we'll use it
this
->
using_mapping_file
=
true
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment