Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
ccan
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mirror
ccan
Commits
64e9e714
Commit
64e9e714
authored
Jan 19, 2016
by
Rusty Russell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tal/str: fix infinite loop of tal_fmt() with empty string.
Signed-off-by:
Rusty Russell
<
rusty@rustcorp.com.au
>
parent
97a1ba3d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
1 deletion
+23
-1
ccan/tal/str/str.c
ccan/tal/str/str.c
+1
-1
ccan/tal/str/test/run-fmt-terminate.c
ccan/tal/str/test/run-fmt-terminate.c
+22
-0
No files found.
ccan/tal/str/str.c
View file @
64e9e714
...
...
@@ -52,7 +52,7 @@ char *tal_fmt(const tal_t *ctx, const char *fmt, ...)
static
bool
do_vfmt
(
char
**
buf
,
size_t
off
,
const
char
*
fmt
,
va_list
ap
)
{
/* A decent guess to start. */
size_t
max
=
strlen
(
fmt
)
*
2
;
size_t
max
=
strlen
(
fmt
)
*
2
+
1
;
bool
ok
;
for
(;;)
{
...
...
ccan/tal/str/test/run-fmt-terminate.c
0 → 100644
View file @
64e9e714
#include <ccan/tal/str/str.h>
#include <stdlib.h>
#include <stdio.h>
#include <ccan/tal/str/str.c>
#include <ccan/tap/tap.h>
#include "helper.h"
/* Empty format string: should still terminate! */
int
main
(
int
argc
,
char
*
argv
[])
{
char
*
str
;
const
char
*
fmt
=
""
;
plan_tests
(
1
);
/* GCC complains about empty format string, complains about non-literal
* with no args... */
str
=
tal_fmt
(
NULL
,
fmt
,
""
);
ok1
(
!
strcmp
(
str
,
""
));
tal_free
(
str
);
return
exit_status
();
}
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