Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tarantool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
core
tarantool
Commits
f82473f7
Commit
f82473f7
authored
10 years ago
by
Roman Tsisyk
Browse files
Options
Downloads
Patches
Plain Diff
Fix #493: Segmentation fault with isnil
parent
45182c81
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/lua/uuid.lua
+12
-0
12 additions, 0 deletions
src/lua/uuid.lua
test/box/uuid.result
+22
-1
22 additions, 1 deletion
test/box/uuid.result
test/box/uuid.test.lua
+10
-0
10 additions, 0 deletions
test/box/uuid.test.lua
with
44 additions
and
1 deletion
src/lua/uuid.lua
+
12
−
0
View file @
f82473f7
...
...
@@ -36,6 +36,9 @@ local UUID_LEN = ffi.sizeof(uuid_t)
local
uuidbuf
=
ffi
.
new
(
uuid_t
)
local
uuid_tostring
=
function
(
uu
)
if
not
ffi
.
istype
(
uuid_t
,
uu
)
then
return
error
(
'Usage: uuid:str()'
)
end
return
ffi
.
string
(
builtin
.
tt_uuid_str
(
uu
),
UUID_STR_LEN
)
end
...
...
@@ -62,6 +65,9 @@ local need_bswap = function(order)
end
local
uuid_tobin
=
function
(
uu
,
byteorder
)
if
not
ffi
.
istype
(
uuid_t
,
uu
)
then
return
error
(
'Usage: uuid:bin([byteorder])'
)
end
if
need_bswap
(
byteorder
)
then
if
uu
~=
uuidbuf
then
ffi
.
copy
(
uuidbuf
,
uu
,
UUID_LEN
)
...
...
@@ -85,6 +91,9 @@ local uuid_frombin = function(bin, byteorder)
end
local
uuid_isnil
=
function
(
uu
)
if
not
ffi
.
istype
(
uuid_t
,
uu
)
then
return
error
(
'Usage: uuid:isnil()'
)
end
return
builtin
.
tt_uuid_is_nil
(
uu
)
end
...
...
@@ -92,6 +101,9 @@ local uuid_eq = function(lhs, rhs)
if
not
ffi
.
istype
(
uuid_t
,
rhs
)
then
return
false
end
if
not
ffi
.
istype
(
uuid_t
,
lhs
)
then
return
error
(
'Usage: uuid == var'
)
end
return
builtin
.
tt_uuid_is_equal
(
lhs
,
rhs
)
end
...
...
This diff is collapsed.
Click to expand it.
test/box/uuid.result
+
22
−
1
View file @
f82473f7
...
...
@@ -106,7 +106,7 @@ uu.node[5]
-- invalid values
uuid.fromstr(nil)
---
- error: 'builtin/uuid.lua:4
4
: fromstr(str)'
- error: 'builtin/uuid.lua:4
7
: fromstr(str)'
...
uuid.fromstr('')
---
...
...
@@ -244,6 +244,27 @@ uu == "blablabla"
---
- false
...
--
-- invalid usage
--
uu = uuid.new()
---
...
uu.isnil()
---
- error: 'Usage: uuid:isnil()'
...
uu.bin()
---
- error: 'Usage: uuid:bin([byteorder])'
...
uu.str()
---
- error: 'Usage: uuid:str()'
...
uu = nil
---
...
uuid = nil
---
...
This diff is collapsed.
Click to expand it.
test/box/uuid.test.lua
+
10
−
0
View file @
f82473f7
...
...
@@ -85,4 +85,14 @@ uu == nil
uu
==
12345
uu
==
"blablabla"
--
-- invalid usage
--
uu
=
uuid
.
new
()
uu
.
isnil
()
uu
.
bin
()
uu
.
str
()
uu
=
nil
uuid
=
nil
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