snep: Fix possible memory leak in snep_read
authorSzymon Janc <szymon.janc@tieto.com>
Tue, 7 Aug 2012 12:22:34 +0000 (14:22 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Tue, 14 Aug 2012 15:28:46 +0000 (17:28 +0200)
Free previously allocated snep_data if nfc_data allocation failed
before returning error.

plugins/snep.c

index 8a8c3b6..c5d5d00 100644 (file)
@@ -242,8 +242,10 @@ static near_bool_t snep_read(int client_fd,
                return FALSE;
 
        snep_data->nfc_data = g_try_malloc0(ndef_length + TLV_SIZE);
-       if (snep_data->nfc_data == NULL)
+       if (snep_data->nfc_data == NULL) {
+               g_free(snep_data);
                return FALSE;
+       }
 
        snep_data->nfc_data_length = ndef_length;
        snep_data->nfc_data_ptr = snep_data->nfc_data;