mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Cleanup: return copied string from hashstring()
The following statement in the hashstring() function: return hashOf[QString(filename)].toHex().data(); returns data of the temporary QByteArray generated by toHex(). Thus, the caller will access released memory, which could lead to data corruption. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
88d0ce499d
commit
e880948d73
2 changed files with 5 additions and 3 deletions
|
@ -435,8 +435,10 @@ static void save_picture(struct membuffer *b, struct picture *pic)
|
|||
put_degrees(b, pic->latitude, " gps='", " ");
|
||||
put_degrees(b, pic->longitude, "", "'");
|
||||
}
|
||||
if (hashstring(pic->filename))
|
||||
put_format(b, " hash='%s'", hashstring(pic->filename));
|
||||
char *hash = hashstring(pic->filename);
|
||||
if (!empty_string(hash))
|
||||
put_format(b, " hash='%s'", hash);
|
||||
free(hash);
|
||||
|
||||
put_string(b, "/>\n");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue