Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
doxverilog
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
doxverilog
Commits
1f44278e
Commit
1f44278e
authored
Sep 08, 2013
by
Dimitri van Heesch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid accessing uninitialized memory in fileToString
parent
5386a768
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
1 deletion
+6
-1
bufstr.h
src/bufstr.h
+6
-1
No files found.
src/bufstr.h
View file @
1f44278e
...
...
@@ -33,7 +33,7 @@ class BufStr
BufStr
(
int
size
)
:
m_size
(
size
),
m_writeOffset
(
0
),
m_spareRoom
(
10240
),
m_buf
(
0
)
{
m_buf
=
(
char
*
)
malloc
(
size
);
m_buf
=
(
char
*
)
calloc
(
size
,
1
);
}
~
BufStr
()
{
...
...
@@ -62,12 +62,17 @@ class BufStr
}
void
resize
(
uint
newlen
)
{
uint
oldsize
=
m_size
;
m_size
=
newlen
;
if
(
m_writeOffset
>=
m_size
)
// offset out of range -> enlarge
{
m_size
=
m_writeOffset
+
m_spareRoom
;
}
m_buf
=
(
char
*
)
realloc
(
m_buf
,
m_size
);
if
(
m_size
>
oldsize
)
{
memset
(
m_buf
+
oldsize
,
0
,
m_size
-
oldsize
);
}
}
int
size
()
const
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment