Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
e3a2e4e4
Commit
e3a2e4e4
authored
Oct 25, 2008
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
str_format_time: do not hard-code buffer length - fix #2242
parent
7f347265
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
7 deletions
+23
-7
src/text/strings.c
src/text/strings.c
+23
-7
No files found.
src/text/strings.c
View file @
e3a2e4e4
...
...
@@ -641,22 +641,38 @@ char *vlc_b64_decode( const char *psz_src )
return
p_dst
;
}
/****************************************************************************
* String formating functions
****************************************************************************/
/**
* Formats current time into a heap-allocated string.
* @param tformat time format (as with C strftime())
* @return an allocated string (must be free()'d), or NULL on memory error.
*/
char
*
str_format_time
(
const
char
*
tformat
)
{
char
buffer
[
255
];
time_t
curtime
;
struct
tm
loctime
;
if
(
strcmp
(
tformat
,
""
)
==
0
)
return
strdup
(
""
);
/* corner case w.r.t. strftime() return value */
/* Get the current time. */
curtime
=
time
(
NULL
);
time
(
&
curtime
);
/* Convert it to local time representation. */
localtime_r
(
&
curtime
,
&
loctime
);
strftime
(
buffer
,
255
,
tformat
,
&
loctime
);
return
strdup
(
buffer
);
for
(
size_t
buflen
=
strlen
(
tformat
)
+
32
;;
buflen
+=
32
)
{
char
*
str
=
malloc
(
buflen
);
if
(
str
==
NULL
)
return
NULL
;
size_t
len
=
strftime
(
str
,
buflen
,
tformat
,
&
loctime
);
if
(
len
>
0
)
{
char
*
ret
=
realloc
(
str
,
len
+
1
);
return
ret
?
ret
:
str
;
/* <- this cannot fail */
}
}
assert
(
0
);
}
#define INSERT_STRING( string ) \
...
...
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