Skip to content

Commit 6aa6002

Browse files
committed
librc: use xasprintf in rc_service_description
1 parent 68b1f2d commit 6aa6002

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

src/librc/librc.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -857,17 +857,14 @@ rc_service_description(const char *service, const char *option)
857857
char *desc = NULL;
858858
size_t size = 0;
859859
FILE *fp;
860-
size_t l;
861860

862861
if (!(svc = rc_service_resolve(service)))
863862
return NULL;
864863

865864
if (!option)
866865
option = "";
867866

868-
l = strlen(DESCSTR) + strlen(svc) + strlen(option) + 2;
869-
cmd = xmalloc(sizeof(char) * l);
870-
snprintf(cmd, l, DESCSTR, svc, *option ? "_" : "", option);
867+
xasprintf(&cmd, DESCSTR, svc, *option ? "_" : "", option);
871868
free(svc);
872869
if ((fp = popen(cmd, "r"))) {
873870
if (xgetline(&desc, &size, fp) == -1) {

0 commit comments

Comments
 (0)