]> sigrok.org Git - libsigrok.git/commitdiff
ASIX Sigma: Improve error handling a bit.
authorUwe Hermann <redacted>
Sat, 16 Apr 2011 14:04:32 +0000 (16:04 +0200)
committerUwe Hermann <redacted>
Sat, 16 Apr 2011 16:08:18 +0000 (18:08 +0200)
hardware/asix-sigma/asix-sigma.c

index 598d0b065ad22c0ee68524a05cf31892d07b3da2..71116dbe0138c8ef31a32057aa8dc4df4e254e94 100644 (file)
@@ -333,11 +333,14 @@ static int bin2bitbang(const char *filename,
 
        if (!(compressed_buf = g_try_malloc(file_size))) {
                sr_err("asix: %s: compressed_buf malloc failed", __func__);
+               fclose(f);
                return SR_ERR_MALLOC;
        }
 
        if (!(firmware = g_try_malloc(buffer_size))) {
                sr_err("asix: %s: firmware malloc failed", __func__);
+               fclose(f);
+               g_free(compressed_buf);
                return SR_ERR_MALLOC;
        }
 
@@ -364,6 +367,8 @@ static int bin2bitbang(const char *filename,
        *buf = p = (unsigned char *)g_try_malloc(*buf_size);
        if (!p) {
                sr_err("asix: %s: buf/p malloc failed", __func__);
+               g_free(compressed_buf);
+               g_free(firmware);
                return SR_ERR_MALLOC;
        }
 
@@ -432,7 +437,7 @@ static int hw_init(const char *deviceinfo)
 
        return 1;
 free:
-       free(sigma);
+       g_free(sigma);
        return 0;
 }