mem leakage: free old malloced buffer on errors (Coverity CID 2056 NetBSD Scan 5)
This commit is contained in:
parent
ee0722e2b9
commit
80b13f6f4e
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: refclock_oncore.c,v 1.5 2004/10/30 15:01:32 dsl Exp $ */
|
/* $NetBSD: refclock_oncore.c,v 1.6 2006/03/18 13:44:15 kardel Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ----------------------------------------------------------------------------
|
* ----------------------------------------------------------------------------
|
||||||
|
@ -903,6 +903,8 @@ oncore_init_shmem(
|
||||||
|
|
||||||
if ((instance->shmemfd = open(instance->shmem_fname, O_RDWR|O_CREAT|O_TRUNC, 0644)) < 0) {
|
if ((instance->shmemfd = open(instance->shmem_fname, O_RDWR|O_CREAT|O_TRUNC, 0644)) < 0) {
|
||||||
perror(instance->shmem_fname);
|
perror(instance->shmem_fname);
|
||||||
|
if (shmem_old)
|
||||||
|
free(shmem_old);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -937,6 +939,8 @@ oncore_init_shmem(
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
perror("malloc");
|
perror("malloc");
|
||||||
close(instance->shmemfd);
|
close(instance->shmemfd);
|
||||||
|
if (shmem_old)
|
||||||
|
free(shmem_old);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue