diff options
author | daniel <danieruru@gmail.com> | 2013-01-31 10:46:02 +0900 |
---|---|---|
committer | daniel <danieruru@gmail.com> | 2013-01-31 10:46:02 +0900 |
commit | d70e8c144505fd57d4a019e5a88468b9960c493e (patch) | |
tree | 7e4ff35cbd34316885c02b6085f940850c6a2e9a /libvxi11client | |
parent | b86adb692fc2080199e76eaec1c27cb8c47feaf2 (diff) |
Return null from open if something failed.
Diffstat (limited to 'libvxi11client')
-rw-r--r-- | libvxi11client/perlbits/perlglue.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libvxi11client/perlbits/perlglue.c b/libvxi11client/perlbits/perlglue.c index dafc707..5c9f4c2 100644 --- a/libvxi11client/perlbits/perlglue.c +++ b/libvxi11client/perlbits/perlglue.c @@ -49,11 +49,17 @@ static void interruptcallback(gchar* handle) { */ VXI11Context* glue_open(char* address, char* device) { - VXI11Context* context = malloc(sizeof(VXI11Context)); + VXI11Context* context = g_malloc(sizeof(VXI11Context)); if (context == NULL ) return NULL ; - int err = vxi11_open(context, address, device); + int ret = vxi11_open(context, address, device); + // if the connection fails dump the context and return null + // so perl can see what happened + if (ret < 1) { + g_free(context); + context = NULL; + } return context; } |