fixed potential use before initialization

This commit is contained in:
cozis
2022-04-24 23:59:37 +02:00
parent cec593c6fc
commit f89d0ce6d2
+5 -2
View File
@@ -132,7 +132,8 @@ static void xj_preport(xj_error *error, const char *src, int off, const char *fm
{ {
if(error != NULL) if(error != NULL)
{ {
int row, col; int row = -1,
col = -1;
if(src != NULL) if(src != NULL)
{ {
// Calculate column and row given // Calculate column and row given
@@ -1368,7 +1369,7 @@ static _Bool encode_string(const char *str, int len, buffer_t *buff)
} }
else if((unsigned char) str[i] < 32) else if((unsigned char) str[i] < 32)
{ {
char *m; char *m = NULL;
switch(str[i]) switch(str[i])
{ {
case '\t': m = "\\t"; break; case '\t': m = "\\t"; break;
@@ -1382,6 +1383,8 @@ static _Bool encode_string(const char *str, int len, buffer_t *buff)
break; break;
} }
assert(m != NULL);
if(!append_string(buff, m, 2)) if(!append_string(buff, m, 2))
return 0; return 0;