Skip to content

Commit 1d4fc1c

Browse files
committed
librc: use xasprintf in rc_service_description
1 parent 77fb635 commit 1d4fc1c

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/librc/librc.c

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

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

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

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

0 commit comments

Comments
 (0)