Module: xenomai-abe
Branch: analogy
Commit: 7b161a2f983a0ba196377b3e71897ce86bb50b74
URL:    
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=7b161a2f983a0ba196377b3e71897ce86bb50b74

Author: Alexis Berlemont <alexis.berlem...@gmail.com>
Date:   Wed Nov 25 13:48:52 2009 +0100

analogy: fix bad error handling path in test programs

---

 src/utils/analogy/cmd_read.c   |    5 +++--
 src/utils/analogy/cmd_write.c  |    5 +++--
 src/utils/analogy/insn_read.c  |    2 +-
 src/utils/analogy/insn_write.c |    2 +-
 4 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/utils/analogy/cmd_read.c b/src/utils/analogy/cmd_read.c
index f665ccd..99bdab8 100644
--- a/src/utils/analogy/cmd_read.c
+++ b/src/utils/analogy/cmd_read.c
@@ -109,7 +109,7 @@ int main(int argc, char *argv[])
        unsigned int i, scan_size = 0, cnt = 0;
        unsigned long buf_size;
        void *map = NULL;
-       a4l_desc_t dsc;
+       a4l_desc_t dsc = { .sbdata = NULL };
 
        /* Compute arguments */
        while ((ret = getopt_long(argc,
@@ -411,7 +411,8 @@ out_main:
                munmap(map, buf_size);
 
        /* Free the buffer used as device descriptor */
-       free(dsc.sbdata);
+       if (dsc.sbdata != NULL)
+               free(dsc.sbdata);
 
        /* Release the file descriptor */
        a4l_close(&dsc);
diff --git a/src/utils/analogy/cmd_write.c b/src/utils/analogy/cmd_write.c
index 05b648a..9fe536e 100644
--- a/src/utils/analogy/cmd_write.c
+++ b/src/utils/analogy/cmd_write.c
@@ -114,7 +114,7 @@ int main(int argc, char *argv[])
        unsigned int i, scan_size = 0, cnt = 0;
        unsigned long buf_size;
        void *map = NULL;
-       a4l_desc_t dsc;
+       a4l_desc_t dsc = { .sbdata = NULL };
 
        /* Compute arguments */
        while ((ret = getopt_long(argc,
@@ -405,7 +405,8 @@ int main(int argc, char *argv[])
 out_main:
 
        /* Free the buffer used as device descriptor */
-       free(dsc.sbdata);
+       if (dsc.sbdata != NULL)
+               free(dsc.sbdata);
 
        /* Release the file descriptor */
        a4l_close(&dsc);
diff --git a/src/utils/analogy/insn_read.c b/src/utils/analogy/insn_read.c
index f4029be..50f2c98 100644
--- a/src/utils/analogy/insn_read.c
+++ b/src/utils/analogy/insn_read.c
@@ -77,7 +77,7 @@ int main(int argc, char *argv[])
 {
        int ret = 0, i;
        unsigned int cnt = 0;
-       a4l_desc_t dsc;
+       a4l_desc_t dsc = { .sbdata = NULL };
        a4l_chinfo_t *chinfo;
        a4l_rnginfo_t *rnginfo;
 
diff --git a/src/utils/analogy/insn_write.c b/src/utils/analogy/insn_write.c
index f5bda70..6da24da 100644
--- a/src/utils/analogy/insn_write.c
+++ b/src/utils/analogy/insn_write.c
@@ -77,7 +77,7 @@ int main(int argc, char *argv[])
 {
        int ret = 0;
        unsigned int cnt = 0;
-       a4l_desc_t dsc;
+       a4l_desc_t dsc = { .sbdata = NULL };
        a4l_chinfo_t *chinfo;
        a4l_rnginfo_t *rnginfo;
 


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to