osa_adb_init_db() maintains a static linked list mapping filenames to
lock structures. Entries are never removed from the list; when their
reference counts hit 0, the lockfile is closed but the filename
remains allocated. However, the filename is allocated each time the
lockfile is re-opened, leaking the old value. Fix this leak by moving
filename initialization to entry creation.
ticket: 8432 (new)
target_version: 1.14-next
tags: pullup
return ENOMEM;
}
memset(lockp, 0, sizeof(*lockp));
+ lockp->lockinfo.filename = strdup(lockfilename);
+ if (lockp->lockinfo.filename == NULL) {
+ free(lockp);
+ free(db);
+ return ENOMEM;
+ }
lockp->next = locklist;
locklist = lockp;
}
* needs be open read/write so that write locking can work with
* POSIX systems
*/
- lockp->lockinfo.filename = strdup(lockfilename);
if ((lockp->lockinfo.lockfile = fopen(lockfilename, "r+")) == NULL) {
/*
* maybe someone took away write permission so we could only