Hi Pina,
sorry, i don't know how to reopen a closed issue (#6).
The ERROR IS NOT FIXED!
The code "(fullTopicStr + topicLen+1) = '\0' writes 1 Byte behind the allocated memory!
Allocation code: "char* fullTopicStr = (char*) calloc(topicLen+1, sizeof(char));"
The management data of the pool or other important data may already be stored there.
Example: topicLen = 20:
-> 21 Bytes are allocated (from Byte *(fullTopicStr+0) till *(fullTopicStr+20) or *(fullTopicStr + topicLen))
-> "(fullTopicStr + topicLen+1) = '\0' writes at Byte 21 behind memory at pointer *fullTopicStr
-> my proposal for line 78: fullTopicStr[topicLen] = '\0'; or *(fullTopicStr + topicLen) = '\0';
Best regards Walter
PS: calloc() clears all bits in the allocated memory. The ending '\0' does not have to be written ;) ... behind the allocated memory
Hi Pina,
sorry, i don't know how to reopen a closed issue (#6).
The ERROR IS NOT FIXED!
The code "(fullTopicStr + topicLen+1) = '\0' writes 1 Byte behind the allocated memory!
Allocation code: "char* fullTopicStr = (char*) calloc(topicLen+1, sizeof(char));"
The management data of the pool or other important data may already be stored there.
Example: topicLen = 20:
-> 21 Bytes are allocated (from Byte *(fullTopicStr+0) till *(fullTopicStr+20) or *(fullTopicStr + topicLen))
-> "(fullTopicStr + topicLen+1) = '\0' writes at Byte 21 behind memory at pointer *fullTopicStr
-> my proposal for line 78: fullTopicStr[topicLen] = '\0'; or *(fullTopicStr + topicLen) = '\0';
Best regards Walter
PS: calloc() clears all bits in the allocated memory. The ending '\0' does not have to be written ;) ... behind the allocated memory