diff options
| author | Franklin Wei <git@fwei.tk> | 2016-01-26 11:34:40 -0500 |
|---|---|---|
| committer | Franklin Wei <git@fwei.tk> | 2016-01-26 11:34:40 -0500 |
| commit | fd4df830de4d9fdc399b8088e5cc801e052391c4 (patch) | |
| tree | 1dc410c7e743e673ad8ad00ce332202fab06c177 /src/util.c | |
| parent | a1acf425cfb00a41c7862c915eb024207658c814 (diff) | |
| download | netcosm-fd4df830de4d9fdc399b8088e5cc801e052391c4.zip netcosm-fd4df830de4d9fdc399b8088e5cc801e052391c4.tar.gz netcosm-fd4df830de4d9fdc399b8088e5cc801e052391c4.tar.bz2 netcosm-fd4df830de4d9fdc399b8088e5cc801e052391c4.tar.xz | |
fix some memory leaks and a serialization bug
Diffstat (limited to 'src/util.c')
| -rw-r--r-- | src/util.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -17,6 +17,7 @@ */ #include "globals.h" +#include <sys/resource.h> void remove_cruft(char *str) { @@ -90,7 +91,11 @@ room_id read_roomid(int fd) char *read_string(int fd) { size_t sz; - read(fd, &sz, sizeof(sz)); + if(read(fd, &sz, sizeof(sz)) != sizeof(sz)) + { + error("read_string: EOF"); + } + debugf("sz is %d\n", sz); char *ret = malloc(sz + 1); if(read(fd, ret, sz) < 0) { |