Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
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
Main
Synchronet
Commits
7d4ce533
Commit
7d4ce533
authored
19 years ago
by
deuce
Browse files
Options
Downloads
Patches
Plain Diff
If the sprintf() returns < 0 then do not modify the format specifier.
parent
b478a530
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/xpdev/xpprintf.c
+20
-16
20 additions, 16 deletions
src/xpdev/xpprintf.c
with
20 additions
and
16 deletions
src/xpdev/xpprintf.c
+
20
−
16
View file @
7d4ce533
...
...
@@ -1121,25 +1121,29 @@ char *xp_asprintf_next(char *format, int type, ...)
break
;
}
this_format_len
=
strlen
(
this_format
);
/*
* This isn't necessary if it's already the right size,
* or it's too large... this realloc() should only need to grow
* the string.
*/
newbuf
=
(
char
*
)
realloc
(
format
,
format_len
-
this_format_len
+
j
);
if
(
newbuf
==
NULL
)
{
if
(
j
>=
0
)
{
this_format_len
=
strlen
(
this_format
);
/*
* This isn't necessary if it's already the right size,
* or it's too large... this realloc() should only need to grow
* the string.
*/
newbuf
=
(
char
*
)
realloc
(
format
,
format_len
-
this_format_len
+
j
);
if
(
newbuf
==
NULL
)
{
if
(
entry
!=
entry_buf
)
free
(
entry
);
return
(
NULL
);
}
format
=
newbuf
;
/* Move trailing end to make space */
memmove
(
format
+
offset
+
j
,
format
+
offset
+
this_format_len
,
format_len
-
offset
-
this_format_len
);
memcpy
(
format
+
offset
,
entry
,
j
);
if
(
entry
!=
entry_buf
)
free
(
entry
);
return
(
NULL
)
;
p
=
format
+
offset
+
j
;
}
format
=
newbuf
;
/* Move trailing end to make space */
memmove
(
format
+
offset
+
j
,
format
+
offset
+
this_format_len
,
format_len
-
offset
-
this_format_len
);
memcpy
(
format
+
offset
,
entry
,
j
);
if
(
entry
!=
entry_buf
)
free
(
entry
);
p
=
format
+
offset
+
j
;
else
p
=
format_offset
+
this_format_len
;
/*
* Search for next non-%% separateor and set offset
* to zero if none found for wrappers to know when
...
...
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