dll: fsp_fuse_opt_add_opt: testing

This commit is contained in:
Bill Zissimopoulos 2016-05-28 17:53:11 -07:00
parent 7ea13a967a
commit 3d3dcbe0c5

View File

@ -495,22 +495,24 @@ static int fsp_fuse_opt_add_opt_internal(char **opts, const char *opt, int escap
newopts = memalloc(optsize + optlen + 1); newopts = memalloc(optsize + optlen + 1);
if (0 == newopts) if (0 == newopts)
return -1; return -1;
memfree(*opts);
*opts = newopts;
if (0 != optsize) if (0 != optsize)
{ {
memcpy(newopts, *opts, optsize - 1); memcpy(newopts, *opts, optsize - 1);
newopts[optsize - 1] = ','; newopts[optsize - 1] = ',';
newopts += optsize;
} }
memfree(*opts);
*opts = newopts;
newopts += optsize;
for (p = opt; *p; p++, newopts++) for (p = opt; *p; p++, newopts++)
{ {
if (escaped && (',' == *p || '\\' == *p)) if (escaped && (',' == *p || '\\' == *p))
*newopts++ = '\\'; *newopts++ = '\\';
*newopts = *p; *newopts = *p;
} }
*newopts = '\0';
return 0; return 0;
} }