Naviserver FB Infer Static Analysis - Sun Jun 18 11:26:32 UTC 2017
Infer version v0.11.0

Found 28 issues

BUG 0: nsd/tclcache.c:611: error: NULL_DEREFERENCE
  pointer `cPtr` last assigned on line 559 could be null and is dereferenced at line 611, column 28
  609.                   } else if (Tcl_ListObjAppendElement(interp, valObj, objv[i]) != TCL_OK) {
  610.                       result = TCL_ERROR;
  611. >                     break;
  612.                   }
  613.               }

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

BUG 2: nsd/tcljob.c:913: error: NULL_DEREFERENCE
  pointer `queue` last assigned on line 897 could be null and is dereferenced at line 913, column 16
  911.           {"queueId",  ObjvQueue,     &queue,       NULL},
  912.           {"jobId",    Ns_ObjvString, &jobIdString, NULL},
  913. >         {NULL, NULL, NULL, NULL}
  914.       };
  915.   

BUG 3: nsd/tcljob.c:1038: error: NULL_DEREFERENCE
  pointer `queue` last assigned on line 1015 could be null and is dereferenced at line 1038, column 39
  1036.   
  1037.       } else {
  1038. >         const Tcl_HashEntry *hPtr;
  1039.           Tcl_HashSearch       search;
  1040.           Tcl_Obj             *listObj = Tcl_NewListObj(0, NULL);

BUG 4: nsd/tcljob.c:725: error: NULL_DEREFERENCE
  pointer `queue` last assigned on line 698 could be null and is dereferenced at line 725, column 16
  723.   
  724.           if (deltaTimeoutPtr != NULL) {
  725. >             /*
  726.                * Set the timeout time. This is an absolute time.
  727.                */

BUG 5: nsd/tclcache.c:310: error: NULL_DEREFERENCE
  pointer `cPtr` last assigned on line 246 could be null and is dereferenced at line 310, column 26
  308.   
  309.           assert(cPtr != NULL);
  310. > 
  311.           Tcl_DStringInit(&ds);
  312.   

BUG 6: nsd/tclcache.c:413: error: NULL_DEREFERENCE
  pointer `cPtr` last assigned on line 371 could be null and is dereferenced at line 413, column 28
  411.               Ns_CacheUnlock(cPtr->cache);
  412.               Tcl_SetObjResult(interp, resultObj);
  413. >             status = TCL_OK;
  414.   
  415.           } else {

BUG 7: nsd/tclcache.c:406: error: NULL_DEREFERENCE
  pointer `cPtr` last assigned on line 371 could be null and is dereferenced at line 406, column 28
  404.           entry = CreateEntry(itPtr, cPtr, key, &isNew, timeoutPtr);
  405.           if (unlikely(entry == NULL)) {
  406. >             status = TCL_ERROR;
  407.               
  408.           } else if (likely(isNew == 0 && force == 0)) {

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

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

BUG 10: nsd/tclcache.c:744: error: NULL_DEREFERENCE
  pointer `cPtr` last assigned on line 696 could be null and is dereferenced at line 744, column 22
  742.           
  743.       } else {
  744. >         Ns_CacheSearch  search;
  745.           Tcl_Obj        *listObj = Tcl_NewListObj(0, NULL);
  746.           

BUG 11: nsd/tclcache.c:958: error: NULL_DEREFERENCE
  pointer `cPtr` last assigned on line 935 could be null and is dereferenced at line 958, column 17
  956.           {"cache", ObjvCache, &cPtr, clientData},
  957.           {NULL, NULL, NULL, NULL}
  958. >     };
  959.       args[0].arg = clientData; /* pass non-constant clientData for "cache" */
  960.   

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:1014: error: NULL_DEREFERENCE
  pointer `chars` last assigned on line 980 could be null and is dereferenced by call to `UrlDecode()` at line 1014, column 15
  1012.   
  1013.           assert(chars != NULL);
  1014. >         
  1015.           Ns_DStringInit(&ds);
  1016.           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:259: error: NULL_DEREFERENCE
  pointer `mutexPtr` last assigned on line 257 could be null and is dereferenced at line 259, column 9
  257.   #endif
  258.   
  259. >     NS_NONNULL_ASSERT(mutex != NULL);
  260.   
  261.       mutexPtr = GETMUTEX(mutex);

BUG 20: nsthread/mutex.c:321: error: NULL_DEREFERENCE
  pointer `mutexPtr` last assigned on line 320 could be null and is dereferenced at line 321, column 20
  319.   Ns_MutexTryLock(Ns_Mutex *mutex)
  320.   {
  321. >     Mutex *mutexPtr;
  322.   
  323.       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