diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-04-14 17:45:26 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-04-14 17:45:26 +0200 |
commit | 42c5aaf3ba3eb9e11a1a2cad105e0dd956ac9763 (patch) | |
tree | 231405000cd34664efddba48e7719f750d088c4f /src/libsystemd-bus/bus-message.c | |
parent | ed5c5dbde1575d74c87ae9856fe61268d7ae8f4b (diff) |
bus: fix counting of argN= matches
Diffstat (limited to 'src/libsystemd-bus/bus-message.c')
-rw-r--r-- | src/libsystemd-bus/bus-message.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/libsystemd-bus/bus-message.c b/src/libsystemd-bus/bus-message.c index e970d093cb..103e2c1f65 100644 --- a/src/libsystemd-bus/bus-message.c +++ b/src/libsystemd-bus/bus-message.c @@ -3263,8 +3263,8 @@ int bus_message_read_strv_extend(sd_bus_message *m, char ***l) { const char* bus_message_get_arg(sd_bus_message *m, unsigned i) { int r; - const char *t; - char type; + const char *t = NULL; + unsigned j; assert(m); @@ -3272,7 +3272,9 @@ const char* bus_message_get_arg(sd_bus_message *m, unsigned i) { if (r < 0) return NULL; - while (i > 0) { + for (j = 0; j <= i; j++) { + char type; + r = sd_bus_message_peek_type(m, &type, NULL); if (r < 0) return NULL; @@ -3285,14 +3287,8 @@ const char* bus_message_get_arg(sd_bus_message *m, unsigned i) { r = sd_bus_message_read_basic(m, type, &t); if (r < 0) return NULL; - - i--; } - r = sd_bus_message_rewind(m, true); - if (r < 0) - return NULL; - return t; } |