diff --git a/source/sigv4.c b/source/sigv4.c
index 0d039f93..b5867b46 100644
--- a/source/sigv4.c
+++ b/source/sigv4.c
@@ -2030,7 +2030,7 @@ static void generateCredentialScope( const SigV4Parameters_t * pSigV4Params,
 
         returnStatus = setQueryStringFieldsAndValues( pQuery, queryLen, &numberOfParameters, pCanonicalContext );
 
-        if( returnStatus == SigV4Success )
+        if( ( returnStatus == SigV4Success ) && ( numberOfParameters > 0U ) )
         {
             /* Sort the parameter names by character code point in ascending order.
              * Parameters with duplicate names should be sorted by value. */
diff --git a/source/sigv4_quicksort.c b/source/sigv4_quicksort.c
index 1618e468..f117b269 100644
--- a/source/sigv4_quicksort.c
+++ b/source/sigv4_quicksort.c
@@ -237,8 +237,10 @@ void quickSort( void * pArray,
                 size_t itemSize,
                 ComparisonFunc_t comparator )
 {
-    if( ( numItems != 0U ) && ( pArray != NULL ) )
-    {
-        quickSortHelper( pArray, 0U, numItems - 1U, itemSize, comparator );
-    }
+    assert( pArray != NULL );
+    assert( numItems > 0U );
+    assert( itemSize > 0U );
+    assert( comparator != NULL );
+
+    quickSortHelper( pArray, 0U, numItems - 1U, itemSize, comparator );
 }