Skip to content

Commit

Permalink
fix(xsnap): free netstring in issueCommand()
Browse files Browse the repository at this point in the history
 - set *dest to 0 on failure
  • Loading branch information
dckc committed May 14, 2021
1 parent ee3344c commit 127e58a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/xsnap/src/xsnap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1389,10 +1389,12 @@ static int fxReadNetString(FILE *inStream, char** dest, size_t* len)
} else {
*(buf + *len) = 0;
}
if (code != 0) {
if (code == 0) {
*dest = buf;
} else {
*dest = 0;
free(buf);
}
*dest = buf;
}
return code;
}
Expand Down Expand Up @@ -1497,6 +1499,7 @@ static void fx_issueCommand(xsMachine *the)
}

xsResult = xsArrayBuffer(buf, len);
free(buf);
}


Expand Down

0 comments on commit 127e58a

Please sign in to comment.