projects
/
ruby-vorbistagger.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Code cleanup.
[ruby-vorbistagger.git]
/
ext
/
vcedit.c
diff --git
a/ext/vcedit.c
b/ext/vcedit.c
index dfad95caf8a807bb5dee614e2590cfa567eaa726..fd89008587c452b23db169e16c5435cc1a88593f 100644
(file)
--- a/
ext/vcedit.c
+++ b/
ext/vcedit.c
@@
-71,10
+71,12
@@
vcedit_state_free (vcedit_state *state)
}
static bool
}
static bool
-vcedit_state_init (vcedit_state *state)
+vcedit_state_init (vcedit_state *state
, const char *filename
)
{
state->refcount = 1;
{
state->refcount = 1;
+ strcpy (state->filename, filename);
+
return true;
}
return true;
}
@@
-85,6
+87,8
@@
vcedit_state_new (const char *filename)
size_t len;
len = strlen (filename);
size_t len;
len = strlen (filename);
+ if (len > PATH_MAX)
+ return NULL;
state = malloc (sizeof (vcedit_state) + len + 1);
if (!state)
state = malloc (sizeof (vcedit_state) + len + 1);
if (!state)
@@
-92,13
+96,11
@@
vcedit_state_new (const char *filename)
memset (state, 0, sizeof (vcedit_state));
memset (state, 0, sizeof (vcedit_state));
- if (!vcedit_state_init (state)) {
+ if (!vcedit_state_init (state
, filename
)) {
vcedit_state_free (state);
return NULL;
}
vcedit_state_free (state);
return NULL;
}
- strcpy (state->filename, filename);
-
return state;
}
return state;
}