If you give base64_encode an empty, non-NULL string it will potentially crash. The fix is: char * base64_encode(void *data, size_t size) { [snip] if(data == NULL) return NULL; + if(size == 0) + return NULL; -Nigel Horne