diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2015-06-08 15:56:33 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2015-06-08 15:57:45 +0100 |
commit | c5a6147a1be440c2d5457f392775e583b2eba8f3 (patch) | |
tree | 871a77e8a777a2eb03c3672e9180921707ef78c5 /overlay | |
parent | fd772e32a23157fc29649070a6a5e94d70ae02f8 (diff) |
overlay: Fix parsing of gem-objects for '[k]' clients
Apparently '[]' are not non-whitespace characters and break '%s'.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'overlay')
-rw-r--r-- | overlay/gem-objects.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/overlay/gem-objects.c b/overlay/gem-objects.c index 4d60299a..8ecc61f5 100644 --- a/overlay/gem-objects.c +++ b/overlay/gem-objects.c @@ -137,8 +137,11 @@ int gem_objects_update(struct gem_objects *obj) while (*b != '\n') b--; + b++; do { + char *eol, *colon; + comm = freed; if (comm) freed = comm->next; @@ -148,11 +151,23 @@ int gem_objects_update(struct gem_objects *obj) break; /* Xorg: 35 objects, 16347136 bytes (0 active, 12103680 inactive, 0 unbound) */ - sscanf(++b, "%256s %lu objects, %lu bytes", - comm->name, &comm->count, &comm->bytes); + eol = strchr(b, '\n'); + if (eol) { + do { + *eol++ = '\0'; + } while (*eol == '\n'); + } + + colon = strchr(b, ':'); + memcpy(comm->name, b, colon-b+1); + comm->name[colon-b+1] = '\0'; + + sscanf(colon + 1, "%lu objects, %lu bytes", + &comm->count, &comm->bytes); insert_sorted(obj, comm); - } while ((b = strchr(b, '\n')) != NULL); + b = eol; + } while (b != NULL); done: while (freed) { |