Fossil SCM

Enhance the blob_eq() macro to help ensure that its second argument is a string literal, not a pointer.

drh 2021-07-06 15:46 trunk
Commit d6477def971855f2230a32c5ad9fcd45272cd5fba7baa664296c4b116b84c749
1 file changed +1 -1
+1 -1
--- src/blob.c
+++ src/blob.c
@@ -474,11 +474,11 @@
474474
** operator on the string constant twice, so it really does need to be a
475475
** string literal or character array - not a character pointer.
476476
*/
477477
#if INTERFACE
478478
# define blob_eq(B,S) \
479
- ((B)->nUsed==sizeof(S)-1 && memcmp((B)->aData,S,sizeof(S)-1)==0)
479
+ ((B)->nUsed==sizeof(S"")-1 && memcmp((B)->aData,S,sizeof(S)-1)==0)
480480
#endif
481481
482482
483483
/*
484484
** Attempt to resize a blob so that its internal buffer is
485485
--- src/blob.c
+++ src/blob.c
@@ -474,11 +474,11 @@
474 ** operator on the string constant twice, so it really does need to be a
475 ** string literal or character array - not a character pointer.
476 */
477 #if INTERFACE
478 # define blob_eq(B,S) \
479 ((B)->nUsed==sizeof(S)-1 && memcmp((B)->aData,S,sizeof(S)-1)==0)
480 #endif
481
482
483 /*
484 ** Attempt to resize a blob so that its internal buffer is
485
--- src/blob.c
+++ src/blob.c
@@ -474,11 +474,11 @@
474 ** operator on the string constant twice, so it really does need to be a
475 ** string literal or character array - not a character pointer.
476 */
477 #if INTERFACE
478 # define blob_eq(B,S) \
479 ((B)->nUsed==sizeof(S"")-1 && memcmp((B)->aData,S,sizeof(S)-1)==0)
480 #endif
481
482
483 /*
484 ** Attempt to resize a blob so that its internal buffer is
485

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button