Permalink
Browse files

fix syscall arg errors reported by valgrind

... when running with empty .ini file.
  • Loading branch information...
1 parent 60d1835 commit 6eeaf6c3a8407e2b967555c0071815b94045c828 @kfish committed Apr 20, 2010
Showing with 6 additions and 4 deletions.
  1. +1 −1 src/libblossom/blossom.c
  2. +2 −0 src/libblossom/flavour.c
  3. +2 −2 src/libblossom/path.c
  4. +1 −1 src/libblossom/template.c
@@ -13,7 +13,7 @@ blossom_open (BlossomConfig * config, const char * path, const char * flavour)
if (path == NULL)
p = getcwd(NULL, 0);
- blossom = (Blossom *) malloc (sizeof (Blossom));
+ blossom = (Blossom *) calloc (1, sizeof (Blossom));
/* Attach config */
blossom->config = config;
@@ -99,6 +99,8 @@ blossom_slurp_content_type (Blossom * blossom)
#endif
path = blossom->template_files[BLOSSOM_TEMPLATE_CONTENT_TYPE];
+ if (path == NULL)
+ return -1;
if (stat (path, &statbuf) == -1)
return -1;
@@ -20,7 +20,7 @@ blossom_path_new (const char * path1, const char * path2)
s = new_path = (char *) malloc (len);
- if (path1) {
+ if (path1 && l1>0) {
strncpy (s, path1, l1);
s += l1;
@@ -34,7 +34,7 @@ blossom_path_new (const char * path1, const char * path2)
s++;
}
- if (path2) {
+ if (path2 && l2>0) {
strncpy (s, path2, l2);
s += l2;
}
@@ -17,7 +17,7 @@ blossom_template_set (Blossom * blossom, BlossomTemplate template)
{
blossom->template_current = template;
- if (template == BLOSSOM_TEMPLATE_END)
+ if (template == BLOSSOM_TEMPLATE_END || blossom->template_files[template] == NULL)
blossom->template_fd = -1;
else
blossom->template_fd = open (blossom->template_files[template], O_RDONLY);

0 comments on commit 6eeaf6c

Please sign in to comment.