Naviserver FB Infer Static Analysis - Mon Dec 11 11:54:42 UTC 2017
Infer version v0.12.1

Found 28 issues

BUG 0: nsperm/nsperm.c:402: error: NULL_DEREFERENCE
  pointer `conn` last assigned on line 375 could be null and is dereferenced by call to `Ns_ConnAuth()` at line 402, column 11
  400.   
  401.       /*
  402. >      * Make sure we have parsed Authentication header properly,
  403.        * otherwise fallback to Basic method
  404.        */

BUG 1: nsd/tclcache.c:668: error: NULL_DEREFERENCE
  pointer `cPtr` last assigned on line 638 could be null and is dereferenced by call to `CreateEntry()` at line 668, column 17
  666.           result = TCL_ERROR;
  667.   
  668. >     } else {
  669.           int                       isNew;
  670.           Ns_Entry                 *entry;

BUG 2: nsd/tcljob.c:841: error: NULL_DEREFERENCE
  pointer `queue` last assigned on line 824 could be null and is dereferenced at line 841, column 16
  839.           {NULL, NULL, NULL, NULL}
  840.       };
  841. > 
  842.       if (Ns_ParseObjv(NULL, args, interp, 2, objc, objv) != NS_OK) {
  843.           result =  TCL_ERROR;

BUG 3: nsd/tcljob.c:909: error: NULL_DEREFERENCE
  pointer `queue` last assigned on line 893 could be null and is dereferenced at line 909, column 16
  907.           {"queueId",  ObjvQueue,     &queue,       NULL},
  908.           {"jobId",    Ns_ObjvString, &jobIdString, NULL},
  909. >         {NULL, NULL, NULL, NULL}
  910.       };
  911.   

BUG 4: nsd/tcljob.c:1034: error: NULL_DEREFERENCE
  pointer `queue` last assigned on line 1011 could be null and is dereferenced at line 1034, column 39
  1032.   
  1033.       } else {
  1034. >         const Tcl_HashEntry *hPtr;
  1035.           Tcl_HashSearch       search;
  1036.           Tcl_Obj             *listObj = Tcl_NewListObj(0, NULL);

BUG 5: nsd/tcljob.c:721: error: NULL_DEREFERENCE
  pointer `queue` last assigned on line 694 could be null and is dereferenced at line 721, column 16
  719.   
  720.           if (deltaTimeoutPtr != NULL) {
  721. >             /*
  722.                * Set the timeout time. This is an absolute time.
  723.                */

BUG 6: nsd/tclcache.c:372: error: NULL_DEREFERENCE
  pointer `cPtr` last assigned on line 308 could be null and is dereferenced at line 372, column 26
  370.           Tcl_DString     ds;
  371.   
  372. >         assert(cPtr != NULL);
  373.   
  374.           Tcl_DStringInit(&ds);

BUG 7: nsd/tclcache.c:468: error: NULL_DEREFERENCE
  pointer `cPtr` last assigned on line 433 could be null and is dereferenced by call to `CreateEntry()` at line 468, column 17
  466.           assert(key != NULL);
  467.   
  468. >         /*
  469.            * CreateEntry waits for ongoing transactions. If it succeeds, it
  470.            * provides either a fresh entry (isNew == 1) or an entry with a

BUG 8: nsd/tclcache.c:879: error: NULL_DEREFERENCE
  pointer `cPtr` last assigned on line 853 could be null and is dereferenced at line 879, column 17
  877.           {NULL, NULL, NULL, NULL}
  878.       };
  879. >     args[0].arg = clientData; /* pass non-constant clientData for "cache" */
  880.   
  881.       if (Ns_ParseObjv(opts, args, interp, 1, objc, objv) != NS_OK) {

BUG 9: nsd/tclcache.c:964: error: NULL_DEREFERENCE
  pointer `cPtr` last assigned on line 941 could be null and is dereferenced at line 964, column 22
  962.       };
  963.       args[0].arg = clientData; /* pass non-constant clientData for "cache" */
  964. > 
  965.       if (Ns_ParseObjv(NULL, args, interp, 1, objc, objv) != NS_OK) {
  966.           result = TCL_ERROR;

BUG 10: nsd/tclcache.c:813: error: NULL_DEREFERENCE
  pointer `cPtr` last assigned on line 763 could be null and is dereferenced at line 813, column 22
  811.           Tcl_SetObjResult(interp, listObj);
  812.   
  813. >     } else {
  814.           Ns_CacheSearch  search;
  815.           Tcl_Obj        *listObj = Tcl_NewListObj(0, NULL);

BUG 11: nsd/tclcache.c:1043: error: NULL_DEREFERENCE
  pointer `cPtr` last assigned on line 1020 could be null and is dereferenced at line 1043, column 17
  1041.       Ns_ObjvSpec args[] = {
  1042.           {"cache", ObjvCache, &cPtr, clientData},
  1043. >         {NULL, NULL, NULL, NULL}
  1044.       };
  1045.       args[0].arg = clientData; /* pass non-constant clientData for "cache" */

BUG 12: nsd/tclmisc.c:677: error: NULL_DEREFERENCE
  pointer `death` last assigned on line 676 could be null and is dereferenced at line 677, column 5
  675.    *      None.
  676.    *
  677. >  * Side effects:
  678.    *      Server will segfault.
  679.    *

BUG 13: nsd/tclmisc.c:510: error: NULL_DEREFERENCE
  pointer `p` last assigned on line 509 could be null and is dereferenced by call to `strchr()` at line 510, column 22
  508.   
  509.       if (Ns_ParseObjv(NULL, args, interp, 1, objc, objv) != NS_OK) {
  510. >         result = TCL_ERROR;
  511.   
  512.       } else {

BUG 14: nsd/tclfile.c:272: error: NULL_DEREFERENCE
  pointer `templateString` last assigned on line 253 could be null and is dereferenced by call to `ns_strdup()` at line 272, column 18
  270.           Tcl_SetObjResult(interp, Tcl_NewStringObj(mktemp(buffer), -1));
  271.           
  272. >     } else /*if (objc == 2)*/ {
  273.           char *buffer;
  274.   

BUG 15: nsd/tcltime.c:525: error: NULL_DEREFERENCE
  pointer `tPtr` last assigned on line 514 could be null and is dereferenced at line 525, column 13
  523.       Ns_ObjvSpec  args[] = {
  524.           {"timespec", Ns_ObjvTime, &tPtr, NULL},
  525. >         {NULL, NULL, NULL, NULL}
  526.       };
  527.   

BUG 16: nsd/tclmisc.c:369: error: NULL_DEREFERENCE
  pointer `htmlString` last assigned on line 348 could be null and is dereferenced by call to `ns_strdup()` at line 369, column 20
  367.           bool        inentity;   /* flag to see if we are inside a special char */
  368.           char       *inString;  /* copy of input string */
  369. >         char       *outPtr;    /* moving pointer to output string */
  370.           const char *inPtr;     /* moving pointer to input string */
  371.   

BUG 17: nsd/urlencode.c:1031: error: NULL_DEREFERENCE
  pointer `chars` last assigned on line 997 could be null and is dereferenced by call to `UrlDecode()` at line 1031, column 15
  1029.   
  1030.           assert(chars != NULL);
  1031. > 
  1032.           Ns_DStringInit(&ds);
  1033.           if (charset != NULL) {

BUG 18: nsd/lisp.c:502: error: MEMORY_LEAK
   `curPtr` is not reachable after line 502, column 13
  500.    *
  501.    *----------------------------------------------------------------------
  502. >  */
  503.   
  504.   Ns_List *

BUG 19: nsthread/mutex.c:263: error: NULL_DEREFERENCE
  pointer `mutexPtr` last assigned on line 261 could be null and is dereferenced at line 263, column 9
  261.   #endif
  262.   
  263. >     NS_NONNULL_ASSERT(mutex != NULL);
  264.   
  265.       mutexPtr = GETMUTEX(mutex);

BUG 20: nsthread/mutex.c:325: error: NULL_DEREFERENCE
  pointer `mutexPtr` last assigned on line 324 could be null and is dereferenced at line 325, column 20
  323.   Ns_MutexTryLock(Ns_Mutex *mutex)
  324.   {
  325. >     Mutex *mutexPtr;
  326.   
  327.       NS_NONNULL_ASSERT(mutex != NULL);

BUG 21: nsthread/rwlock.c:169: error: NULL_DEREFERENCE
  pointer `lockPtr` last assigned on line 161 could be null and is dereferenced at line 169, column 12
  167.       /*
  168.        * Wait on the read condition while the lock is write-locked or
  169. >      * some other thread is waiting for a write lock.
  170.        */
  171.   

BUG 22: nsthread/rwlock.c:207: error: NULL_DEREFERENCE
  pointer `lockPtr` last assigned on line 204 could be null and is dereferenced at line 207, column 12
  205.   
  206.       NS_NONNULL_ASSERT(rwPtr != NULL);
  207. > 
  208.       lockPtr = GetRwLock(rwPtr);
  209.       

BUG 23: nsd/filter.c:107: error: NULL_DEREFERENCE
  pointer `servPtr` last assigned on line 96 could be null and is dereferenced at line 107, column 25
  105.       fPtr->arg = arg;
  106.       Ns_MutexLock(&servPtr->filter.lock);
  107. >     if (first) {
  108.           fPtr->nextPtr = servPtr->filter.firstFilterPtr;
  109.           servPtr->filter.firstFilterPtr = fPtr;

BUG 24: nsd/event.c:281: error: MEMORY_LEAK
   `evPtr` is not reachable after line 281, column 13
  279.        */
  280.       Ns_GetTime(&now);
  281. >     
  282.       while ((evPtr = queuePtr->firstInitPtr) != NULL) {
  283.           queuePtr->firstInitPtr = evPtr->nextPtr;

BUG 25: nsd/init.c:73: error: NULL_DEREFERENCE
  pointer `&nsconf.state.lock` last assigned on line 68 could be null and is dereferenced by call to `Ns_MutexSetName()` at line 73, column 2
  71.           Nsthreads_LibInit();
  72.   	
  73. > 	Ns_MutexInit(&nsconf.state.lock);
  74.   	Ns_MutexSetName(&nsconf.state.lock, "nsd:conf");
  75.   

BUG 26: nsd/config.c:805: error: NULL_DEREFERENCE
  pointer `paramName` last assigned on line 788 could be null and is dereferenced by call to `Ns_SetPut()` at line 805, column 19
  803.       int         result = TCL_OK;
  804.       char       *paramName = NULL, *paramValue = NULL;
  805. >     Ns_ObjvSpec args[] = {
  806.           {"name",  Ns_ObjvString,  ¶mName, NULL},
  807.           {"value", Ns_ObjvString,  ¶mValue, NULL},        

BUG 27: nsd/tclenv.c:320: error: MEMORY_LEAK
   memory dynamically allocated to `s` by call to `malloc()` at line 292, column 9 is not reachable after line 320, column 13
  318.           *(s + nameLength + 1u) = '\0';
  319.   
  320. >         if (value != NULL) {
  321.               strncat(s + nameLength + 1, value, valueLength);
  322.           }

Summary of the reports

  NULL_DEREFERENCE: 25
       MEMORY_LEAK: 3