Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
8404b44a
Commit
8404b44a
authored
Dec 14, 2011
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix new String:realloc* variants always to zero-terminate the string
parent
818af42f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
4 deletions
+16
-4
sql/sql_string.cc
sql/sql_string.cc
+1
-2
sql/sql_string.h
sql/sql_string.h
+15
-2
No files found.
sql/sql_string.cc
View file @
8404b44a
...
...
@@ -81,7 +81,7 @@ bool String::real_alloc(uint32 length)
@retval true An error occured when attempting to allocate memory.
*/
bool
String
::
realloc
(
uint32
alloc_length
)
bool
String
::
realloc
_raw
(
uint32
alloc_length
)
{
if
(
Alloced_length
<=
alloc_length
)
{
...
...
@@ -109,7 +109,6 @@ bool String::realloc(uint32 alloc_length)
Ptr
=
new_ptr
;
Alloced_length
=
len
;
}
Ptr
[
alloc_length
]
=
0
;
// This make other funcs shorter
return
FALSE
;
}
...
...
sql/sql_string.h
View file @
8404b44a
...
...
@@ -255,17 +255,30 @@ public:
return
real_alloc
(
arg_length
);
}
bool
real_alloc
(
uint32
arg_length
);
// Empties old string
bool
realloc
(
uint32
arg_length
);
bool
realloc_raw
(
uint32
arg_length
);
bool
realloc
(
uint32
arg_length
)
{
if
(
realloc_raw
(
arg_length
))
return
TRUE
;
Ptr
[
arg_length
]
=
0
;
// This make other funcs shorter
return
FALSE
;
}
bool
realloc_with_extra
(
uint32
arg_length
)
{
if
(
extra_alloc
<
4096
)
extra_alloc
=
extra_alloc
*
2
+
128
;
return
realloc
(
arg_length
+
extra_alloc
);
if
(
realloc_raw
(
arg_length
+
extra_alloc
))
return
TRUE
;
Ptr
[
arg_length
]
=
0
;
// This make other funcs shorter
return
FALSE
;
}
bool
realloc_with_extra_if_needed
(
uint32
arg_length
)
{
if
(
arg_length
<
Alloced_length
)
{
Ptr
[
arg_length
]
=
0
;
// behave as if realloc was called.
return
0
;
}
return
realloc_with_extra
(
arg_length
);
}
inline
void
shrink
(
uint32
arg_length
)
// Shrink buffer
...
...
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