summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChase Douglas <chase.douglas@canonical.com>2012-02-10 10:48:44 -0800
committerChase Douglas <chase.douglas@canonical.com>2012-02-10 13:20:48 -0800
commit146edc2baad1388f49a7a857c2003faa171876c7 (patch)
tree55428f5c0dcf7ecefadaadfb68589982f63bf5b2 /src
parent49f6109032f2ce6171d1aad02672479d2c78c083 (diff)
Allocate proto data in eventcomm-test
Provide a helper function for allocating proto data and use it in eventcomm-test. This ensures a null pointer for priv->proto_data is not dereferenced. Signed-off-by: Chase Douglas <chase.douglas@canonical.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'src')
-rw-r--r--src/eventcomm.c8
-rw-r--r--src/eventcomm.h5
2 files changed, 12 insertions, 1 deletions
diff --git a/src/eventcomm.c b/src/eventcomm.c
index ce26934..d7d1f86 100644
--- a/src/eventcomm.c
+++ b/src/eventcomm.c
@@ -83,6 +83,12 @@ struct eventcomm_proto_data
#endif
};
+struct eventcomm_proto_data *
+EventProtoDataAlloc(void)
+{
+ return calloc(1, sizeof(struct eventcomm_proto_data));
+}
+
#ifdef HAVE_MTDEV
static int
num_slots(const struct eventcomm_proto_data *proto_data)
@@ -940,7 +946,7 @@ EventReadDevDimensions(InputInfoPtr pInfo)
int i;
#endif
- proto_data = calloc(1, sizeof(struct eventcomm_proto_data));
+ proto_data = EventProtoDataAlloc();
priv->proto_data = proto_data;
#ifdef HAVE_MTDEV
diff --git a/src/eventcomm.h b/src/eventcomm.h
index 1938d5f..70bfc18 100644
--- a/src/eventcomm.h
+++ b/src/eventcomm.h
@@ -36,6 +36,11 @@
#define DEV_INPUT_EVENT "/dev/input"
#define EVENT_DEV_NAME "event"
+struct eventcomm_proto_data;
+
+extern struct eventcomm_proto_data *
+EventProtoDataAlloc(void);
+
extern Bool
EventReadHwState(InputInfoPtr pInfo,
struct CommData *comm, struct SynapticsHwState *hwRet);