Commit c4c525942079471d9cace4dd3d23b749fee1380c
authorDaniel Lockyer <thisisdaniellockyer@gmail.com>
Mon, 25 Jan 2016 15:33:13 +0000 (15:33 +0000)
committerDaniel Lockyer <thisisdaniellockyer@gmail.com>
Mon, 25 Jan 2016 15:33:13 +0000 (15:33 +0000)
simavr/sim/sim_gdb.c

index 6248e6b51d42eade9c76d1337c44ab813be4909f..f2c2b42f91029b4c32f599dfd68ad945e85355e9 100644 (file)
@@ -623,12 +623,12 @@ avr_gdb_init(
 
        if ( network_init() ) {
                AVR_LOG(avr, LOG_ERROR, "GDB: Can't initialize network");
-               return -1;
+               goto error;
        }
        
        if ((g->listen = socket(PF_INET, SOCK_STREAM, 0)) < 0) {
                AVR_LOG(avr, LOG_ERROR, "GDB: Can't create socket: %s", strerror(errno));
-               return -1;
+               goto error;
        }
 
        int optval = 1;
@@ -640,11 +640,11 @@ avr_gdb_init(
 
        if (bind(g->listen, (struct sockaddr *) &address, sizeof(address))) {
                AVR_LOG(avr, LOG_ERROR, "GDB: Can not bind socket: %s", strerror(errno));
-               return -1;
+               goto error;
        }
        if (listen(g->listen, 1)) {
                perror("listen");
-               return -1;
+               goto error;
        }
        printf("avr_gdb_init listening on port %d\n", avr->gdb_port);
        g->avr = avr;
@@ -655,6 +655,10 @@ avr_gdb_init(
        avr->sleep = avr_callback_sleep_gdb;
        
        return 0;
+
+       error:
+               free(g);
+               return -1;
 }
 
 void