mirror of
https://github.com/owntone/owntone-server.git
synced 2025-04-16 09:08:04 -04:00
Fix parser crash on empty strings
This commit is contained in:
parent
1cca7d3a53
commit
75fab9657d
@ -1353,7 +1353,9 @@ int sp_node_size(SP_NODE *node) {
|
|||||||
|
|
||||||
if(node->op_type == SP_OPTYPE_STRING) {
|
if(node->op_type == SP_OPTYPE_STRING) {
|
||||||
string_size = 0;
|
string_size = 0;
|
||||||
|
if((node->right.cvalue) && (strlen(node->right.cvalue)))
|
||||||
db_sql_escape(NULL,&string_size,"%q",node->right.cvalue);
|
db_sql_escape(NULL,&string_size,"%q",node->right.cvalue);
|
||||||
|
|
||||||
size += (2 + string_size);
|
size += (2 + string_size);
|
||||||
if(node->op == T_INCLUDES) {
|
if(node->op == T_INCLUDES) {
|
||||||
size += 2; /* extra %'s */
|
size += 2; /* extra %'s */
|
||||||
@ -1406,12 +1408,15 @@ void sp_serialize_sql(SP_NODE *node, char *string) {
|
|||||||
if((node->op == T_INCLUDES) || (node->op == T_ENDSWITH))
|
if((node->op == T_INCLUDES) || (node->op == T_ENDSWITH))
|
||||||
strcat(string,"%");
|
strcat(string,"%");
|
||||||
size = 0;
|
size = 0;
|
||||||
|
if((node->right.cvalue) && (strlen(node->right.cvalue)))
|
||||||
db_sql_escape(NULL,&size,"%q",node->right.cvalue);
|
db_sql_escape(NULL,&size,"%q",node->right.cvalue);
|
||||||
|
|
||||||
/* we don't have a way to verify we have that much
|
/* we don't have a way to verify we have that much
|
||||||
* room, but we must... we allocated it earlier.
|
* room, but we must... we allocated it earlier.
|
||||||
*/
|
*/
|
||||||
db_sql_escape(&string[strlen(string)],&size,"%q",node->right.cvalue);
|
if((node->right.cvalue) && (strlen(node->right.cvalue)))
|
||||||
|
db_sql_escape(&string[strlen(string)],&size,"%q",
|
||||||
|
node->right.cvalue);
|
||||||
|
|
||||||
// strcat(string,node->right.cvalue);
|
// strcat(string,node->right.cvalue);
|
||||||
if((node->op == T_INCLUDES) || (node->op == T_STARTSWITH))
|
if((node->op == T_INCLUDES) || (node->op == T_STARTSWITH))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user