mirror of
https://github.com/libretro/RetroArch
synced 2025-04-09 21:45:45 +00:00
Replace some snprintf usage where not necessary
This commit is contained in:
parent
a36d5926d7
commit
c3c4638b22
@ -240,10 +240,10 @@ static bool rxml_parse_tag(struct rxml_node *node, const char *str)
|
|||||||
|
|
||||||
static struct rxml_node *rxml_parse_node(const char **ptr_)
|
static struct rxml_node *rxml_parse_node(const char **ptr_)
|
||||||
{
|
{
|
||||||
const char *ptr = NULL;
|
const char *ptr = NULL;
|
||||||
const char *closing = NULL;
|
const char *closing = NULL;
|
||||||
char *str = NULL;
|
char *str = NULL;
|
||||||
bool is_closing = false;
|
bool is_closing = false;
|
||||||
|
|
||||||
struct rxml_node *node = (struct rxml_node*)calloc(1, sizeof(*node));
|
struct rxml_node *node = (struct rxml_node*)calloc(1, sizeof(*node));
|
||||||
if (!node)
|
if (!node)
|
||||||
@ -272,17 +272,25 @@ static struct rxml_node *rxml_parse_node(const char **ptr_)
|
|||||||
/* Look for more data. Either child nodes or data. */
|
/* Look for more data. Either child nodes or data. */
|
||||||
if (!is_closing)
|
if (!is_closing)
|
||||||
{
|
{
|
||||||
size_t closing_tag_size = strlen(node->name) + 4;
|
size_t copied = 0;
|
||||||
char *closing_tag = (char*)malloc(closing_tag_size);
|
size_t closing_tag_size = strlen(node->name) + 4;
|
||||||
|
char *closing_tag = (char*)malloc(closing_tag_size);
|
||||||
|
|
||||||
const char *cdata_start = NULL;
|
const char *cdata_start = NULL;
|
||||||
const char *child_start = NULL;
|
const char *child_start = NULL;
|
||||||
const char *closing_start = NULL;
|
const char *closing_start = NULL;
|
||||||
|
|
||||||
if (!closing_tag)
|
if (!closing_tag)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
snprintf(closing_tag, closing_tag_size, "</%s>", node->name);
|
closing_tag[copied] = '<';
|
||||||
|
closing_tag[copied+1] = '/';
|
||||||
|
closing_tag[copied+2] = '\0';
|
||||||
|
|
||||||
|
copied = strlcat(closing_tag, node->name, closing_tag_size);
|
||||||
|
|
||||||
|
closing_tag[copied] = '>';
|
||||||
|
closing_tag[copied+1] = '\0';
|
||||||
|
|
||||||
cdata_start = strstr(closing + 1, "<![CDATA[");
|
cdata_start = strstr(closing + 1, "<![CDATA[");
|
||||||
child_start = strchr(closing + 1, '<');
|
child_start = strchr(closing + 1, '<');
|
||||||
|
@ -1119,11 +1119,13 @@ static bool dirent_check_error(libretro_vfs_implementation_dir *rdir)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
libretro_vfs_implementation_dir *retro_vfs_opendir_impl(const char *name, bool include_hidden)
|
libretro_vfs_implementation_dir *retro_vfs_opendir_impl(
|
||||||
|
const char *name, bool include_hidden)
|
||||||
{
|
{
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
unsigned path_len;
|
unsigned path_len;
|
||||||
char path_buf[1024];
|
char path_buf[1024];
|
||||||
|
size_t copied = 0;
|
||||||
#if defined(LEGACY_WIN32)
|
#if defined(LEGACY_WIN32)
|
||||||
char *path_local = NULL;
|
char *path_local = NULL;
|
||||||
#else
|
#else
|
||||||
@ -1147,11 +1149,20 @@ libretro_vfs_implementation_dir *retro_vfs_opendir_impl(const char *name, bool i
|
|||||||
path_buf[0] = '\0';
|
path_buf[0] = '\0';
|
||||||
path_len = strlen(name);
|
path_len = strlen(name);
|
||||||
|
|
||||||
|
copied = strlcpy(path_buf, name, sizeof(path_buf));
|
||||||
|
|
||||||
/* Non-NT platforms don't like extra slashes in the path */
|
/* Non-NT platforms don't like extra slashes in the path */
|
||||||
if (name[path_len - 1] == '\\')
|
if (name[path_len - 1] == '\\')
|
||||||
snprintf(path_buf, sizeof(path_buf), "%s*", name);
|
{
|
||||||
|
path_buf[copied] = '*';
|
||||||
|
path_buf[copied+1] = '\0';
|
||||||
|
}
|
||||||
else
|
else
|
||||||
snprintf(path_buf, sizeof(path_buf), "%s\\*", name);
|
{
|
||||||
|
path_buf[copied] = '\\';
|
||||||
|
path_buf[copied+1] = '*';
|
||||||
|
path_buf[copied+2] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(LEGACY_WIN32)
|
#if defined(LEGACY_WIN32)
|
||||||
path_local = utf8_to_local_string_alloc(path_buf);
|
path_local = utf8_to_local_string_alloc(path_buf);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user