android: jpeg: exif: Use reentrant localtime_r()
The std::localtime() function isn't thread-safe, and we have no guarantee whether other threads in the camera service may or may not call it. Replace it with localtime_r(). This requires switching from ctime to time.h, as there is no std::localtime_r() function. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Umang Jain <email@uajain.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
This commit is contained in:
parent
7208e70211
commit
7720c4aefa
2 changed files with 5 additions and 3 deletions
|
@ -186,9 +186,11 @@ void Exif::setSize(const Size &size)
|
|||
|
||||
void Exif::setTimestamp(time_t timestamp)
|
||||
{
|
||||
struct tm tm;
|
||||
localtime_r(×tamp, &tm);
|
||||
|
||||
char str[20];
|
||||
std::strftime(str, sizeof(str), "%Y:%m:%d %H:%M:%S",
|
||||
std::localtime(×tamp));
|
||||
strftime(str, sizeof(str), "%Y:%m:%d %H:%M:%S", &tm);
|
||||
std::string ts(str);
|
||||
|
||||
setString(EXIF_IFD_0, EXIF_TAG_DATE_TIME, EXIF_FORMAT_ASCII, ts);
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
#ifndef __ANDROID_JPEG_EXIF_H__
|
||||
#define __ANDROID_JPEG_EXIF_H__
|
||||
|
||||
#include <ctime>
|
||||
#include <string>
|
||||
#include <time.h>
|
||||
|
||||
#include <libexif/exif-data.h>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue