Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LazyStringMapTemplate::get returns Nullptr wich is not in oatpp.io Documentation #920

Open
tibersam opened this issue Feb 19, 2024 · 0 comments

Comments

@tibersam
Copy link

tibersam commented Feb 19, 2024

Hi all,

Thank you for your work on oatpp.

In my Application i am analyzing the provided Content-Type Header attribute during a multipart/form-data post request of the overall request and the different parts. At first i only looked up the Documentation from the website.
For LazyStringMapTemplate::get it states the return is "Get value as oatpp::String". This tempted my to use the empty function of strings to check if the key Content-Type exists.
I assumed if the key is not present an empty string is returned. The actual returned nullptr crashed the application if the field was not present.

Is it possible to either update the documentation to state that a nullptr is returned the key is not valid or to return an empty string instead of nullptr?

/**
* Get value as &id:oatpp::String;.
* @param key
* @return
*/
String get(const Key& key) const {
std::lock_guard<concurrency::SpinLock> lock(m_lock);
auto it = m_map.find(key);
if(it != m_map.end()) {
it->second.captureToOwnMemory();
return it->second.getMemoryHandle();
}
return nullptr;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant