mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-28 08:05:56 -05:00
[smartpl.g] Fix memleak in smart playlist parsing with string operators
This commit is contained in:
parent
359d12f4ff
commit
43745cf5c3
@ -131,44 +131,62 @@ expression returns [ pANTLR3_STRING result, pANTLR3_STRING orderby, pANTLR3_STRI
|
|||||||
| STRTAG INCLUDES STR
|
| STRTAG INCLUDES STR
|
||||||
{
|
{
|
||||||
pANTLR3_UINT8 val;
|
pANTLR3_UINT8 val;
|
||||||
|
char *tmp;
|
||||||
|
|
||||||
val = $STR.text->toUTF8($STR.text)->chars;
|
val = $STR.text->toUTF8($STR.text)->chars;
|
||||||
val++;
|
val++;
|
||||||
val[strlen((const char *)val) - 1] = '\0';
|
val[strlen((const char *)val) - 1] = '\0';
|
||||||
|
|
||||||
|
tmp = sqlite3_mprintf("\%q", (const char *)val);
|
||||||
|
|
||||||
$result = $STR.text->factory->newRaw($STR.text->factory);
|
$result = $STR.text->factory->newRaw($STR.text->factory);
|
||||||
$result->append8($result, "f.");
|
$result->append8($result, "f.");
|
||||||
$result->appendS($result, $STRTAG.text->toUTF8($STRTAG.text));
|
$result->appendS($result, $STRTAG.text->toUTF8($STRTAG.text));
|
||||||
$result->append8($result, " LIKE '\%");
|
$result->append8($result, " LIKE '\%");
|
||||||
$result->append8($result, sqlite3_mprintf("\%q", (const char *)val));
|
$result->append8($result, tmp);
|
||||||
$result->append8($result, "\%'");
|
$result->append8($result, "\%'");
|
||||||
|
|
||||||
|
sqlite3_free(tmp);
|
||||||
}
|
}
|
||||||
| STRTAG IS STR
|
| STRTAG IS STR
|
||||||
{
|
{
|
||||||
pANTLR3_UINT8 val;
|
pANTLR3_UINT8 val;
|
||||||
|
char *tmp;
|
||||||
|
|
||||||
val = $STR.text->toUTF8($STR.text)->chars;
|
val = $STR.text->toUTF8($STR.text)->chars;
|
||||||
val++;
|
val++;
|
||||||
val[strlen((const char *)val) - 1] = '\0';
|
val[strlen((const char *)val) - 1] = '\0';
|
||||||
|
|
||||||
|
tmp = sqlite3_mprintf("\%q", (const char *)val);
|
||||||
|
|
||||||
$result = $STR.text->factory->newRaw($STR.text->factory);
|
$result = $STR.text->factory->newRaw($STR.text->factory);
|
||||||
$result->append8($result, "f.");
|
$result->append8($result, "f.");
|
||||||
$result->appendS($result, $STRTAG.text->toUTF8($STRTAG.text));
|
$result->appendS($result, $STRTAG.text->toUTF8($STRTAG.text));
|
||||||
$result->append8($result, " LIKE '");
|
$result->append8($result, " LIKE '");
|
||||||
$result->append8($result, sqlite3_mprintf("\%q", (const char *)val));
|
$result->append8($result, tmp);
|
||||||
$result->append8($result, "'");
|
$result->append8($result, "'");
|
||||||
|
|
||||||
|
sqlite3_free(tmp);
|
||||||
}
|
}
|
||||||
| STRTAG STARTSWITH STR
|
| STRTAG STARTSWITH STR
|
||||||
{
|
{
|
||||||
pANTLR3_UINT8 val;
|
pANTLR3_UINT8 val;
|
||||||
|
char *tmp;
|
||||||
|
|
||||||
val = $STR.text->toUTF8($STR.text)->chars;
|
val = $STR.text->toUTF8($STR.text)->chars;
|
||||||
val++;
|
val++;
|
||||||
val[strlen((const char *)val) - 1] = '\0';
|
val[strlen((const char *)val) - 1] = '\0';
|
||||||
|
|
||||||
|
tmp = sqlite3_mprintf("\%q", (const char *)val);
|
||||||
|
|
||||||
$result = $STR.text->factory->newRaw($STR.text->factory);
|
$result = $STR.text->factory->newRaw($STR.text->factory);
|
||||||
$result->append8($result, "f.");
|
$result->append8($result, "f.");
|
||||||
$result->appendS($result, $STRTAG.text->toUTF8($STRTAG.text));
|
$result->appendS($result, $STRTAG.text->toUTF8($STRTAG.text));
|
||||||
$result->append8($result, " LIKE '");
|
$result->append8($result, " LIKE '");
|
||||||
$result->append8($result, sqlite3_mprintf("\%q", (const char *)val));
|
$result->append8($result, tmp);
|
||||||
$result->append8($result, "\%'");
|
$result->append8($result, "\%'");
|
||||||
|
|
||||||
|
sqlite3_free(tmp);
|
||||||
}
|
}
|
||||||
| INTTAG INTBOOL INT
|
| INTTAG INTBOOL INT
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user