Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Nadezhda Ivanova
OpenLDAP
Commits
4022ee7b
Commit
4022ee7b
authored
Apr 05, 2003
by
Pierangelo Masarati
Browse files
avoid 0-sized, unused allocations
parent
c0ee56c3
Changes
1
Hide whitespace changes
Inline
Side-by-side
libraries/librewrite/subst.c
View file @
4022ee7b
...
...
@@ -300,10 +300,12 @@ rewrite_subst_apply(
/*
* Prepare room for submatch expansion
*/
submatch
=
calloc
(
sizeof
(
struct
berval
),
subst
->
lt_num_submatch
);
if
(
submatch
==
NULL
)
{
return
REWRITE_REGEXEC_ERR
;
if
(
subst
->
lt_num_submatch
>
0
)
{
submatch
=
calloc
(
sizeof
(
struct
berval
),
subst
->
lt_num_submatch
);
if
(
submatch
==
NULL
)
{
return
REWRITE_REGEXEC_ERR
;
}
}
/*
...
...
@@ -408,8 +410,8 @@ rewrite_subst_apply(
l
+=
subst
->
lt_subs_len
;
res
=
calloc
(
sizeof
(
char
),
l
+
1
);
if
(
res
==
NULL
)
{
free
(
submatch
)
;
return
REWRITE_REGEXEC_ERR
;
rc
=
REWRITE_REGEXEC_ERR
;
goto
cleanup
;
}
/*
...
...
@@ -433,7 +435,12 @@ rewrite_subst_apply(
val
->
bv_val
=
res
;
val
->
bv_len
=
l
;
cleanup:
;
if
(
submatch
)
{
free
(
submatch
);
}
return
rc
;
}
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment