Naviserver FB Infer Static Analysis - Mon Apr 24 21:45:34 UTC 2017
Infer version v0.11.0

Found 41 issues

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

BUG 1: nsd/encoding.c:229: error: NULL_DEREFERENCE
  pointer `servPtr` last assigned on line 220 could be null and is dereferenced at line 229, column 5
  227.   
  228.       path = Ns_ConfigGetPath(server, NULL, (char *)0);
  229. > 
  230.       servPtr->encoding.urlCharset =
  231.           Ns_ConfigString(path, "urlCharset", "utf-8");

BUG 2: nsd/fastpath.c:142: error: NULL_DEREFERENCE
  pointer `servPtr` last assigned on line 129 could be null and is dereferenced at line 142, column 5
  140.           Ns_Log(Error, "fastpath[%s]: directoryfile is not a list: %s", server, p);
  141.       }
  142. > 
  143.       servPtr->fastpath.serverdir = Ns_ConfigString(path, "serverdir", "");
  144.       if (Ns_PathIsAbsolute(servPtr->fastpath.serverdir) == NS_FALSE) {

BUG 3: nsd/tclinit.c:249: error: NULL_DEREFERENCE
  pointer `servPtr` last assigned on line 241 could be null and is dereferenced at line 249, column 5
  247.       path = Ns_ConfigGetPath(server, NULL, "tcl", (char *)0);
  248.       set = Ns_ConfigCreateSection(path);
  249. > 
  250.       Ns_DStringInit(&ds);
  251.   

BUG 4: nsd/pathname.c:96: error: NULL_DEREFERENCE
  pointer `servPtr` last assigned on line 87 could be null and is dereferenced at line 96, column 5
  94.       
  95.       path = Ns_ConfigGetPath(server, NULL, "vhost", (char *)0);
  96. > 
  97.       servPtr->vhost.enabled = Ns_ConfigBool(path, "enabled", NS_FALSE);
  98.       if (servPtr->vhost.enabled

BUG 5: 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 6: nsd/tcljob.c:910: error: NULL_DEREFERENCE
  pointer `queue` last assigned on line 897 could be null and is dereferenced at line 910, column 38
  908.       int          result = TCL_OK;
  909.       char        *jobIdString;
  910. >     Ns_ObjvSpec  args[] = {
  911.           {"queueId",  ObjvQueue,     &queue,       NULL},
  912.           {"jobId",    Ns_ObjvString, &jobIdString, NULL},

BUG 7: nsd/tcljob.c:1035: error: NULL_DEREFERENCE
  pointer `queue` last assigned on line 1013 could be null and is dereferenced at line 1035, column 39
  1033.           result = TCL_ERROR;
  1034.   
  1035. >     } else {
  1036.           const Tcl_HashEntry *hPtr;
  1037.           Tcl_HashSearch       search;

BUG 8: 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 9: nsd/filter.c:394: error: NULL_DEREFERENCE
  pointer `servPtr` last assigned on line 391 could be null and is dereferenced at line 394, column 12
  392.       const Filter   *fPtr;
  393.       const NsServer *servPtr;
  394. > 
  395.       NS_NONNULL_ASSERT(dsPtr != NULL);
  396.       NS_NONNULL_ASSERT(server != NULL);

BUG 10: nsd/op.c:587: error: NULL_DEREFERENCE
  pointer `servPtr` last assigned on line 583 could be null and is dereferenced at line 587, column 29
  585.   
  586.   void
  587. > NsGetRequestProcs(Tcl_DString *dsPtr, const char *server)
  588.   {
  589.       const NsServer *servPtr;

BUG 11: nsd/filter.c:429: error: NULL_DEREFERENCE
  pointer `servPtr` last assigned on line 426 could be null and is dereferenced at line 429, column 16
  427.       const Trace    *tracePtr;
  428.       const NsServer *servPtr;
  429. > 
  430.       NS_NONNULL_ASSERT(dsPtr != NULL);
  431.       NS_NONNULL_ASSERT(server != NULL);

BUG 12: nsd/tclcache.c:306: error: NULL_DEREFERENCE
  pointer `cPtr` last assigned on line 246 could be null and is dereferenced at line 306, column 26
  304.           Tcl_Obj        *resultObj = Tcl_NewListObj(0, NULL);
  305.           Tcl_DString     ds;
  306. > 
  307.           Tcl_DStringInit(&ds);
  308.   

BUG 13: nsd/tclcache.c:398: error: NULL_DEREFERENCE
  pointer `cPtr` last assigned on line 367 could be null and is dereferenced at line 398, column 28
  396.   
  397.           if (unlikely(entry == NULL)) {
  398. >             status = TCL_ERROR;
  399.               
  400.           } else if (likely(isNew == 0 && force == 0)) {

BUG 14: nsd/tclcache.c:405: error: NULL_DEREFERENCE
  pointer `cPtr` last assigned on line 367 could be null and is dereferenced at line 405, column 28
  403.               Ns_CacheUnlock(cPtr->cache);
  404.               Tcl_SetObjResult(interp, resultObj);
  405. >             status = TCL_OK;
  406.   
  407.           } else {

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

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

BUG 17: nsd/tclcache.c:732: error: NULL_DEREFERENCE
  pointer `cPtr` last assigned on line 684 could be null and is dereferenced at line 732, column 22
  730.           
  731.       } else {
  732. >         Ns_CacheSearch  search;
  733.           Tcl_Obj        *listObj = Tcl_NewListObj(0, NULL);
  734.           

BUG 18: nsd/tclcache.c:946: error: NULL_DEREFERENCE
  pointer `cPtr` last assigned on line 923 could be null and is dereferenced at line 946, column 17
  944.           {"cache", ObjvCache, &cPtr, clientData},
  945.           {NULL, NULL, NULL, NULL}
  946. >     };
  947.       args[0].arg = clientData; /* pass non-constant clientData for "cache" */
  948.   

BUG 19: nsd/tclmisc.c:672: error: NULL_DEREFERENCE
  pointer `death` last assigned on line 671 could be null and is dereferenced at line 672, column 5
  670.    *      None.
  671.    *
  672. >  * Side effects:
  673.    *      Server will segfault.
  674.    *

BUG 20: nsd/tclmisc.c:505: error: NULL_DEREFERENCE
  pointer `p` last assigned on line 502 could be null and is dereferenced by call to `strchr()` at line 505, column 22
  503.           {"html", Ns_ObjvString,  &htmlString, NULL},
  504.           {NULL, NULL, NULL, NULL}
  505. >     };
  506.   
  507.       if (Ns_ParseObjv(NULL, args, interp, 1, objc, objv) != NS_OK) {

BUG 21: nsd/tclfile.c:269: error: NULL_DEREFERENCE
  pointer `templateString` last assigned on line 253 could be null and is dereferenced by call to `ns_strdup()` at line 269, column 17
  267.           char buffer[PATH_MAX] = "";
  268.   
  269. >         snprintf(buffer, sizeof(buffer), "%s/ns-XXXXXX", nsconf.tmpDir);
  270.   	Tcl_SetObjResult(interp, Tcl_NewStringObj(mktemp(buffer), -1));
  271.   

BUG 22: nsd/tcltime.c:522: error: NULL_DEREFERENCE
  pointer `tPtr` last assigned on line 514 could be null and is dereferenced at line 522, column 16
  520.   {
  521.       int          rc = TCL_OK;
  522. >     Ns_Time     *tPtr = NULL;
  523.       Ns_ObjvSpec  args[] = {
  524.           {"timespec", Ns_ObjvTime, &tPtr, NULL},

BUG 23: nsd/tclmisc.c:367: error: NULL_DEREFERENCE
  pointer `htmlString` last assigned on line 348 could be null and is dereferenced by call to `ns_strdup()` at line 367, column 20
  365.       } else {
  366.           bool        intag;     /* flag to see if are we inside a tag */
  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 */

BUG 24: nsd/url2file.c:329: error: NULL_DEREFERENCE
  pointer `servPtr` last assigned on line 327 could be null and is dereferenced by call to `Ns_FastUrl2FileProc()` at line 329, column 12
  327.    *
  328.    *----------------------------------------------------------------------
  329. >  */
  330.   
  331.   Ns_ReturnCode

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

BUG 26: nsthread/mutex.c:256: error: NULL_DEREFERENCE
  pointer `mutexPtr` last assigned on line 255 could be null and is dereferenced at line 256, column 9
  254.       Ns_GetTime(&startTime);
  255.   #endif
  256. > 
  257.       NS_NONNULL_ASSERT(mutex != NULL);
  258.   

BUG 27: nsthread/mutex.c:318: error: NULL_DEREFERENCE
  pointer `mutexPtr` last assigned on line 317 could be null and is dereferenced at line 318, column 20
  316.   Ns_MutexTryLock(Ns_Mutex *mutex)
  317.   {
  318. >     Mutex *mutexPtr;
  319.   
  320.       NS_NONNULL_ASSERT(mutex != NULL);

BUG 28: 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 29: 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 30: 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 31: nsd/url2file.c:146: error: NULL_DEREFERENCE
  pointer `servPtr` last assigned on line 143 could be null and is dereferenced at line 146, column 5
  144.   {
  145.       NsServer *servPtr = NsGetServer(server);
  146. >     Url2File *u2fPtr;
  147.   
  148.       servPtr->fastpath.url2file = NULL;

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

BUG 33: nsd/url2file.c:304: error: NULL_DEREFERENCE
  pointer `servPtr` last assigned on line 302 could be null and is dereferenced at line 304, column 5
  302.    *----------------------------------------------------------------------
  303.    */
  304. > 
  305.   void
  306.   Ns_SetUrlToFileProc(const char *server, Ns_UrlToFileProc *procPtr)

BUG 34: nsd/urlspace.c:639: error: NULL_DEREFERENCE
  pointer `servPtr` last assigned on line 634 could be null and is dereferenced by call to `JunctionGet()` at line 639, column 29
  637.       NS_NONNULL_ASSERT(url != NULL);
  638.   
  639. >     servPtr = NsGetServer(server);
  640.   
  641.       Ns_DStringInit(&ds);

BUG 35: nsd/urlspace.c:642: error: NULL_DEREFERENCE
  pointer `servPtr` last assigned on line 634 could be null and is dereferenced by call to `JunctionGet()` at line 642, column 35
  640.   
  641.       Ns_DStringInit(&ds);
  642. >     MkSeq(&ds, method, url);
  643.       if ((flags & NS_OP_RECURSE) != 0u) {
  644.           JunctionTruncBranch(JunctionGet(servPtr, id), ds.string);

BUG 36: nsd/urlspace.c:471: error: NULL_DEREFERENCE
  pointer `servPtr` last assigned on line 462 could be null and is dereferenced by call to `JunctionGet()` at line 471, column 17
  469.   #ifdef DEBUG
  470.       PrintSeq(ds.string);
  471. > #endif
  472.       
  473.       JunctionAdd(JunctionGet(servPtr, id), ds.string, data, flags, deletefunc);

BUG 37: nsd/url2file.c:241: error: NULL_DEREFERENCE
  pointer `servPtr` last assigned on line 240 could be null and is dereferenced by call to `NsUrlToFile()` at line 241, column 12
  239.       NsServer *servPtr;
  240.   
  241. >     NS_NONNULL_ASSERT(dsPtr != NULL);
  242.       NS_NONNULL_ASSERT(server != NULL);
  243.       NS_NONNULL_ASSERT(url != NULL);

BUG 38: 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 39: nsd/config.c:797: error: NULL_DEREFERENCE
  pointer `paramName` last assigned on line 783 could be null and is dereferenced by call to `Ns_SetPut()` at line 797, column 19
  795.   static int
  796.   ParamObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST* objv)
  797. > {
  798.       int         result = TCL_OK;
  799.       char       *paramName = NULL, *paramValue = NULL;

BUG 40: 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: 38
       MEMORY_LEAK: 3