chiark
/
gitweb
/
~ian
/
inn-innduct.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix memory management of argument to open_input_file
[inn-innduct.git]
/
backends
/
innduct.c
diff --git
a/backends/innduct.c
b/backends/innduct.c
index 2a22ba20a937b0acdd5d845c43e4bc15f3ff66c3..f0cbf3496c830ad177967cbfb83fa2252359dfb0 100644
(file)
--- a/
backends/innduct.c
+++ b/
backends/innduct.c
@@
-259,7
+259,6
@@
typedef struct InputFile {
void *readable_callback_user;
int fd;
void *readable_callback_user;
int fd;
- const char *path; /* ptr copy of path_<foo> or feedfile */
struct Filemon_Perfile *filemon;
oop_read *rd;
struct Filemon_Perfile *filemon;
oop_read *rd;
@@
-267,6
+266,7
@@
typedef struct InputFile {
off_t offset;
Counts counts;
off_t offset;
Counts counts;
+ char path[];
} InputFile;
typedef enum {
} InputFile;
typedef enum {
@@
-1113,7
+1113,7
@@
static InputFile *open_input_file(const char *path) {
sysfatal("unable to open input file %s", path);
}
sysfatal("unable to open input file %s", path);
}
- InputFile *ipf= xmalloc(sizeof(
InputFile)
);
+ InputFile *ipf= xmalloc(sizeof(
*ipf) + strlen(path) + 1
);
memset(ipf,0,sizeof(*ipf));
ipf->readable.on_readable= tailing_on_readable;
memset(ipf,0,sizeof(*ipf));
ipf->readable.on_readable= tailing_on_readable;
@@
-1121,7
+1121,7
@@
static InputFile *open_input_file(const char *path) {
ipf->readable.try_read= tailing_try_read;
ipf->fd= fd;
ipf->readable.try_read= tailing_try_read;
ipf->fd= fd;
-
ipf->path= path
;
+
strcpy(ipf->path, path)
;
return ipf;
}
return ipf;
}
@@
-1135,8
+1135,6
@@
static void close_input_file(InputFile *ipf) {
if (ipf->fd >= 0)
if (close(ipf->fd)) sysdie("could not close input file %s", ipf->path);
if (ipf->fd >= 0)
if (close(ipf->fd)) sysdie("could not close input file %s", ipf->path);
- fixme maybe free ipf->path;
-
free(ipf);
}
free(ipf);
}
@@
-1818,7
+1816,7
@@
static int search_backlog_file(void) {
debug("backlog scan: found age=%f deficiency=%ld oldest=%s",
age, age_deficiency, oldest_path);
debug("backlog scan: found age=%f deficiency=%ld oldest=%s",
age, age_deficiency, oldest_path);
- backlog_input_file= open_input_file();
+ backlog_input_file= open_input_file(
oldest_path
);
if (!backlog_input_file) {
warn("backlog file %s vanished as we opened it", backlog_input_file);
goto try_again;
if (!backlog_input_file) {
warn("backlog file %s vanished as we opened it", backlog_input_file);
goto try_again;