#2 nsd/tclcrypto.c:231: error: Null Dereference pointer `outputBuffer` last assigned on line 211 could be null and is dereferenced by call to `Ns_HexString()` at line 231, column 9. nsd/tclcrypto.c:198:1: start of procedure EncodedObj() 196. */ 197. 198. static Tcl_Obj* ^ 199. EncodedObj(unsigned char *octects, size_t octectLength, 200. char *outputBuffer, Ns_BinaryEncoding encoding) { nsd/tclcrypto.c:201:5: 199. EncodedObj(unsigned char *octects, size_t octectLength, 200. char *outputBuffer, Ns_BinaryEncoding encoding) { 201. char *origOutputBuffer = outputBuffer; ^ 202. Tcl_Obj *resultObj = NULL; /* enumeration is complete, quiet some older compilers */ 203. nsd/tclcrypto.c:202:5: 200. char *outputBuffer, Ns_BinaryEncoding encoding) { 201. char *origOutputBuffer = outputBuffer; 202. Tcl_Obj *resultObj = NULL; /* enumeration is complete, quiet some older compilers */ ^ 203. 204. NS_NONNULL_ASSERT(octects != NULL); nsd/tclcrypto.c:204:5: 202. Tcl_Obj *resultObj = NULL; /* enumeration is complete, quiet some older compilers */ 203. 204. NS_NONNULL_ASSERT(octects != NULL); ^ 205. 206. if (outputBuffer == NULL && encoding != RESULT_ENCODING_BINARY) { nsd/tclcrypto.c:206:9: Taking true branch 204. NS_NONNULL_ASSERT(octects != NULL); 205. 206. if (outputBuffer == NULL && encoding != RESULT_ENCODING_BINARY) { ^ 207. /* 208. * It is a safe assumption to double the size, since the hex nsd/tclcrypto.c:206:33: Taking true branch 204. NS_NONNULL_ASSERT(octects != NULL); 205. 206. if (outputBuffer == NULL && encoding != RESULT_ENCODING_BINARY) { ^ 207. /* 208. * It is a safe assumption to double the size, since the hex nsd/tclcrypto.c:211:9: 209. * encoding needs the most space. 210. */ 211. outputBuffer = ns_malloc(octectLength * 2u + 1u); ^ 212. } 213. nsthread/memory.c:72:1: start of procedure ns_malloc() 70. return result; 71. } 72. void *ns_malloc(size_t size) { ^ 73. void *result; 74. #ifdef NS_VERBOSE_MALLOC nsthread/memory.c:83:5: 81. * in general, that a malloc() result of NULL means out of memory. 82. */ 83. result = malloc(size); ^ 84. /*if (size == 0u) { 85. fprintf(stderr, "ZERO ns_malloc size=%lu ptr %p\n", size, result); nsthread/memory.c:87:9: Condition is true 85. fprintf(stderr, "ZERO ns_malloc size=%lu ptr %p\n", size, result); 86. }*/ 87. if (unlikely(result == NULL && size > 0u)) { ^ 88. fprintf(stderr, "Fatal: failed to allocate %" PRIuz " bytes.\n", size); 89. abort(); nsthread/memory.c:87:9: Condition is false 85. fprintf(stderr, "ZERO ns_malloc size=%lu ptr %p\n", size, result); 86. }*/ 87. if (unlikely(result == NULL && size > 0u)) { ^ 88. fprintf(stderr, "Fatal: failed to allocate %" PRIuz " bytes.\n", size); 89. abort(); nsthread/memory.c:87:9: Taking false branch 85. fprintf(stderr, "ZERO ns_malloc size=%lu ptr %p\n", size, result); 86. }*/ 87. if (unlikely(result == NULL && size > 0u)) { ^ 88. fprintf(stderr, "Fatal: failed to allocate %" PRIuz " bytes.\n", size); 89. abort(); nsthread/memory.c:91:5: 89. abort(); 90. } 91. return result; ^ 92. } 93. void ns_free(void *ptr) { nsthread/memory.c:92:1: return from a call to ns_malloc 90. } 91. return result; 92. } ^ 93. void ns_free(void *ptr) { 94. free(ptr); nsd/tclcrypto.c:214:5: 212. } 213. 214. switch (encoding) { ^ 215. case RESULT_ENCODING_BINARY: 216. resultObj = Tcl_NewByteArrayObj(octects, (int)octectLength); nsd/tclcrypto.c:215:5: Switch condition is false. Skipping switch case 213. 214. switch (encoding) { 215. case RESULT_ENCODING_BINARY: ^ 216. resultObj = Tcl_NewByteArrayObj(octects, (int)octectLength); 217. break; nsd/tclcrypto.c:219:5: Switch condition is false. Skipping switch case 217. break; 218. 219. case RESULT_ENCODING_BASE64URL: ^ 220. hexPrint("result", octects, octectLength); 221. (void)Ns_HtuuEncode2(octects, octectLength, outputBuffer, 1); nsd/tclcrypto.c:225:5: Switch condition is false. Skipping switch case 223. break; 224. 225. case RESULT_ENCODING_BASE64: ^ 226. (void)Ns_HtuuEncode2(octects, octectLength, outputBuffer, 0); 227. resultObj = Tcl_NewStringObj(outputBuffer, (int)strlen(outputBuffer)); nsd/tclcrypto.c:230:5: Switch condition is true. Entering switch case 228. break; 229. 230. case RESULT_ENCODING_HEX: ^ 231. Ns_HexString(octects, outputBuffer, (int)octectLength, NS_FALSE); 232. resultObj = Tcl_NewStringObj(outputBuffer, (int)octectLength*2); nsd/tclcrypto.c:231:9: 229. 230. case RESULT_ENCODING_HEX: 231. Ns_HexString(octects, outputBuffer, (int)octectLength, NS_FALSE); ^ 232. resultObj = Tcl_NewStringObj(outputBuffer, (int)octectLength*2); 233. break; nsd/tclmisc.c:1385:1: start of procedure Ns_HexString() 1383. *---------------------------------------------------------------------- 1384. */ 1385. char * ^ 1386. Ns_HexString(const unsigned char *octets, char *outputBuffer, int size, bool isUpper) 1387. { nsd/tclmisc.c:1389:5: 1387. { 1388. int i; 1389. static const char hexCharsUpper[] = "0123456789ABCDEF"; ^ 1390. static const char hexCharsLower[] = "0123456789abcdef"; 1391. nsd/tclmisc.c:1390:5: 1388. int i; 1389. static const char hexCharsUpper[] = "0123456789ABCDEF"; 1390. static const char hexCharsLower[] = "0123456789abcdef"; ^ 1391. 1392. NS_NONNULL_ASSERT(octets != NULL); nsd/tclmisc.c:1392:5: 1390. static const char hexCharsLower[] = "0123456789abcdef"; 1391. 1392. NS_NONNULL_ASSERT(octets != NULL); ^ 1393. NS_NONNULL_ASSERT(outputBuffer != NULL); 1394. nsd/tclmisc.c:1393:5: 1391. 1392. NS_NONNULL_ASSERT(octets != NULL); 1393. NS_NONNULL_ASSERT(outputBuffer != NULL); ^ 1394. 1395. if (isUpper) { nsd/tclmisc.c:1395:9: Taking false branch 1393. NS_NONNULL_ASSERT(outputBuffer != NULL); 1394. 1395. if (isUpper) { ^ 1396. for (i = 0; i < size; ++i) { 1397. outputBuffer[i * 2] = hexCharsUpper[octets[i] >> 4]; nsd/tclmisc.c:1401:14: 1399. } 1400. } else { 1401. for (i = 0; i < size; ++i) { ^ 1402. outputBuffer[i * 2] = hexCharsLower[octets[i] >> 4]; 1403. outputBuffer[i * 2 + 1] = hexCharsLower[octets[i] & 0xFu]; nsd/tclmisc.c:1401:21: Loop condition is false. Leaving loop 1399. } 1400. } else { 1401. for (i = 0; i < size; ++i) { ^ 1402. outputBuffer[i * 2] = hexCharsLower[octets[i] >> 4]; 1403. outputBuffer[i * 2 + 1] = hexCharsLower[octets[i] & 0xFu]; nsd/tclmisc.c:1406:5: 1404. } 1405. } 1406. outputBuffer[size * 2] = '\0'; ^ 1407. 1408. return outputBuffer;