diff options
| author | fusion32 <marcopuzziello@gmail.com> | 2025-07-12 20:44:10 -0300 |
|---|---|---|
| committer | fusion32 <marcopuzziello@gmail.com> | 2025-07-12 20:44:10 -0300 |
| commit | 1cad8468cbaf61309a64194fca547a67a700a6da (patch) | |
| tree | 603ed4e52f28ec502bd2c820a133b42022cd8f37 /src/querymanager.cc | |
| parent | ac41dc912dbdee28a01a4db0404bdb363d5530dc (diff) | |
| download | querymanager-1cad8468cbaf61309a64194fca547a67a700a6da.tar.gz querymanager-1cad8468cbaf61309a64194fca547a67a700a6da.zip | |
house related queries
Diffstat (limited to 'src/querymanager.cc')
| -rw-r--r-- | src/querymanager.cc | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/querymanager.cc b/src/querymanager.cc index 57b3ef9..7d6c830 100644 --- a/src/querymanager.cc +++ b/src/querymanager.cc @@ -112,17 +112,21 @@ bool StringEqCI(const char *A, const char *B){ bool StringCopyN(char *Dest, int DestCapacity, const char *Src, int SrcLength){ ASSERT(DestCapacity > 0); bool Result = (SrcLength < DestCapacity); - if(Result){ + if(Result && SrcLength > 0){ memcpy(Dest, Src, SrcLength); Dest[SrcLength] = 0; }else{ Dest[0] = 0; } - return true; + return Result; } bool StringCopy(char *Dest, int DestCapacity, const char *Src){ - return StringCopyN(Dest, DestCapacity, Src, (int)strlen(Src)); + // IMPORTANT(fusion): `sqlite3_column_text` may return NULL if the column is + // also NULL so we have an incentive to properly handle the case where `Src` + // is NULL. + int SrcLength = (Src != NULL ? (int)strlen(Src) : 0); + return StringCopyN(Dest, DestCapacity, Src, SrcLength); } bool ReadBooleanConfig(bool *Dest, const char *Val){ |
