diff options
author | Linux Build Service Account <lnxbuild@localhost> | 2014-05-09 01:05:32 -0700 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2014-05-09 01:05:31 -0700 |
commit | 9c0fe9145565c41dd749c12f131606c71626474f (patch) | |
tree | 8f5fdaef71ea63093d458c8d86bdee5305253147 | |
parent | 98619d8897ed0bbe51146f760954a257d2db4d4e (diff) | |
parent | 001b30942d137b532f25edecac34633612a31a0a (diff) | |
download | display-9c0fe9145565c41dd749c12f131606c71626474f.tar.gz |
Merge "hqd: Fix Klocwork errors in liblight"
-rw-r--r-- | liblight/lights.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/liblight/lights.c b/liblight/lights.c index 1aa0b588..6fd12904 100644 --- a/liblight/lights.c +++ b/liblight/lights.c @@ -83,7 +83,7 @@ write_int(char const* path, int value) fd = open(path, O_RDWR); if (fd >= 0) { char buffer[20]; - int bytes = sprintf(buffer, "%d\n", value); + int bytes = snprintf(buffer, sizeof(buffer), "%d\n", value); ssize_t amt = write(fd, buffer, (size_t)bytes); close(fd); return amt == -1 ? -errno : 0; @@ -271,6 +271,10 @@ static int open_lights(const struct hw_module_t* module, char const* name, pthread_once(&g_init, init_globals); struct light_device_t *dev = malloc(sizeof(struct light_device_t)); + + if(!dev) + return -ENOMEM; + memset(dev, 0, sizeof(*dev)); dev->common.tag = HARDWARE_DEVICE_TAG; |